home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-imap-imap2bis-01.txt < prev    next >
Text File  |  1993-10-01  |  113KB  |  2,973 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                       Mark Crispin
  8. Internet Draft: IMAP2bis                        University of Washington
  9. Obsoletes: RFC 1176, 1064                                   October 1993
  10. Document: internet-drafts/draft-ietf-imap-imap2bis-01.txt
  11.  
  12.  
  13.             INTERACTIVE MAIL ACCESS PROTOCOL - VERSION 2bis
  14.  
  15.  
  16. Status of this Memo
  17.  
  18.    This document is an Internet Draft.  Internet Drafts are working
  19.    documents of the Internet Engineering Task Force (IETF), its Areas,
  20.    and its Working Groups. Note that other groups may also distribute
  21.    working documents as Internet Drafts.
  22.  
  23.    Internet Drafts are draft documents valid for a maximum of six
  24.    months.  Internet Drafts may be updated, replaced, or obsoleted by
  25.    other documents at any time.  It is not appropriate to use Internet
  26.    Drafts as reference material or to cite them other than as a "working
  27.    draft" or "work in progress".  Please check the I-D abstract listing
  28.    contained in each Internet Draft directory to learn the current
  29.    status of any this or any other Internet Draft.
  30.  
  31.    This is a draft document of the IETF IMAP Working Group.  It is a
  32.    draft specification of the IMAP2bis protocol, based upon the
  33.    following earlier specifications: unpublished IMAP2bis.TXT document,
  34.    RFC 1176, and RFC 1064.  This document is not a complete or final
  35.    specification of the IMAP2bis protocol.
  36.  
  37.    Only matters that are believed to be uncontroversial, or issues that
  38.    are believed to be resolved, appear in this document.  The entirety
  39.    of this document is subject to change and extension.  A list of open
  40.    issues may be found in the file mail/imap.unresolved on Internet site
  41.    ftp.CAC.Washington.EDU.
  42.  
  43.    A version of this draft document will be submitted to the RFC editor
  44.    as a Proposed Standard for the Internet Community.  Discussion and
  45.    suggestions for improvement are requested.  This document will expire
  46.    before 31 March 1994.  Distribution of this draft is unlimited.
  47.    Comments are solicited and should be sent to imap@CAC.Washington.EDU.
  48.  
  49.  
  50. Introduction
  51.  
  52.    The Interactive Mail Access Protocol, Version 2bis (IMAP2bis) allows
  53.    a client to access and manipulate electronic mail on a server.
  54.    IMAP2bis is designed to permit manipulations of remote mailboxes as
  55.  
  56.  
  57.  
  58. Crispin                                                         [Page 1]
  59.  
  60. Internet Draft                  IMAP2bis              September 30, 1993
  61.  
  62.  
  63.    if they were local.  IMAP2bis includes operations for creating,
  64.    deleting, and renaming mailbox folders; checking for new mail;
  65.    permanently removing messages; setting and clearing flags; RFC 822
  66.    and MIME parsing; searching; and selective fetching of message
  67.    attributes, texts, and portions thereof.
  68.  
  69.    IMAP2bis does not specify a means of posting mail; this function is
  70.    handled by a mail transfer protocol such as SMTP (RFC 821).
  71.  
  72.    IMAP2bis assumes a reliable data stream such as provided by TCP.
  73.    When TCP is used, an IMAP2bis server listens on port 143.
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Crispin                                                         [Page 2]
  115.  
  116. Internet Draft                  IMAP2bis              September 30, 1993
  117.  
  118.  
  119. System Model and Philosophy
  120.  
  121.    There are three fundamental models of client/server email: offline,
  122.    online, and disconnected use.  IMAP2bis can be used in any one of
  123.    these three models.
  124.  
  125.    The offline model is the most familiar form of client/server email
  126.    today, and is used by protocols such as POP-3 (RFC 1225) and UUCP.
  127.    In this model, a client application periodically connects to a
  128.    server.  It downloads all the pending messages to the client machine
  129.    and deletes these from the server.  Thereafter, all mail processing
  130.    is local to the client.  This model is store-and-forward; it moves
  131.    mail on demand from an intermediate server (maildrop) to a single
  132.    destination machine.
  133.  
  134.    The online model is most commonly used with remote filesystem
  135.    protocols such as NFS.  In this model, a client application
  136.    manipulates mailbox data on a server machine.  A connection to the
  137.    server is maintained throughout the session.  No mailbox data are
  138.    kept on the client; the client retrieves data from the server as is
  139.    needed.  IMAP2bis introduces a form of the online model that requires
  140.    considerably less network bandwidth than a remote filesystem
  141.    protocol, and provides the opportunity for using the server for CPU
  142.    or I/O intensive functions such as parsing and searching.
  143.  
  144.    The disconnected use model is a hybrid of the offline and online
  145.    models, and is used by protocols such as PCMAIL (RFC 1056).  In this
  146.    model, a client user downloads some set of messages from the server,
  147.    manipulates them offline, then at some later time uploads the
  148.    changes.  The server remains the authoritative repository of the
  149.    messages.  The problems of synchronization (particularly when
  150.    multiple clients are involved) are handled through the means of
  151.    unique identifiers for each message.
  152.  
  153.    Each of these models have their own strengths and weaknesses:
  154.  
  155.       Feature                               Offline Online  Disc
  156.       -------                               ------- ------  ----
  157.       Can use multiple clients               NO      YES     YES
  158.       Minimum use of server connect time     YES     NO      YES
  159.       Minimum use of server resources        YES     NO      NO
  160.       Minimum use of client disk resources   NO      YES     NO
  161.       Multiple remote mailboxes              NO      YES     YES
  162.       Fast startup                           NO      YES     NO
  163.       Mail processing when not online        YES     NO      YES
  164.  
  165.    Although IMAP2bis was originally designed to accommodate the online
  166.    model, it can support the other two models as well.  This makes
  167.  
  168.  
  169.  
  170. Crispin                                                         [Page 3]
  171.  
  172. Internet Draft                  IMAP2bis              September 30, 1993
  173.  
  174.  
  175.    possible the creation of clients that can be used in any of the three
  176.    models.  For example, a user may wish to switch between the online
  177.    and disconnected models on a regular basis (e.g. owing to travel).
  178.  
  179.    IMAP2bis is designed to transmit message data on demand, and to
  180.    provide the facilities necessary for a client to decide what data it
  181.    needs at any particular time.  There is generally no need to do a
  182.    wholesale transfer of an entire mailbox or even of the complete text
  183.    of a message.  This makes a difference in situations where the
  184.    mailbox is large, or when the link to the server is slow.
  185.  
  186.    More specifically, IMAP2bis supports server-based RFC 822 and MIME
  187.    processing.  With this information, it is possible for a client to
  188.    determine in advance whether it wishes to retrieve a particular
  189.    message or part of a message.  For example, a user connected to an
  190.    IMAP2bis server via a dialup link can determine that a message has a
  191.    2000 byte text segment and a 40 megabyte video segment, and elect to
  192.    fetch only the text segment.
  193.  
  194.    In IMAP2bis, the client/server relationship lasts only for the
  195.    duration of the TCP connection, and mailbox state is maintained on
  196.    the server.  There is no registration of clients.  Except for any
  197.    unique identifiers used in disconnected use operation, the client
  198.    initially has no knowledge of mailbox state and learns it from the
  199.    IMAP2bis server when a mailbox is selected.  This initial transfer is
  200.    minimal; the client requests additional state data as it needs.
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. Crispin                                                         [Page 4]
  227.  
  228. Internet Draft                  IMAP2bis              September 30, 1993
  229.  
  230.  
  231. The Protocol
  232.  
  233.    The IMAP2bis protocol consists of a sequence of client commands and
  234.    server responses, with server data interspersed between the
  235.    responses.  Unlike most Internet protocols, commands and responses
  236.    are tagged.  That is, a command begins with a unique identifier
  237.    (typically a short alphanumeric sequence such as a Lisp "gensym"
  238.    function would generate e.g., A0001, A0002, etc.) called a tag.  The
  239.    response to the command is given the same tag from the server.
  240.  
  241.    Additionally, the server may send an arbitrary amount of "unsolicited
  242.    data".  Unsolicited data is identified by the special reserved tag of
  243.    "*".  The unsolicited data mechanism transmits most data in IMAP2bis.
  244.    The term "unsolicited data" suggests that the data may have been
  245.    transmitted without any explicit request by the client for that data.
  246.    No distinction is made in IMAP2bis between data transmitted as a
  247.    result of a client command and data that are unilaterally transmitted
  248.    by the server.  One form of unilaterally transmitted data that
  249.    commonly occurs is an alert of a change to the mailbox made by some
  250.    process other than the IMAP2bis client or server; for example,
  251.    changes in the size of the mailbox (new mail) or in the status of
  252.    individual messages.
  253.  
  254.    There is another special reserved tag, "+", discussed below.
  255.  
  256.    The server must be listening for a connection.  When a connection is
  257.    opened the server sends a greeting message and then waits for
  258.    commands.  This greeting is either a PREAUTH (meaning that the user
  259.    has already been identified and authenticated by an external
  260.    mechanism such as rsh) or OK (meaning that the user is not yet
  261.    authenticated) unsolicited response.  The server may also send a BYE
  262.    unsolicited response and close the connection if it rejects the
  263.    connection.
  264.  
  265.    The client opens a connection and waits for the greeting.  The client
  266.    must not send any commands until it has received the greeting from
  267.    the server.
  268.  
  269.    Once the greeting has been received, the client may begin sending
  270.    commands.  It is not under any obligation to wait for a server
  271.    response to a command before sending another command, subject to the
  272.    constraints of underlying flow control.  When commands are received
  273.    the server acts on them and responds with command responses, often
  274.    interspersed with data.
  275.  
  276.    In general, the command responses do not themselves contain the
  277.    requested data.  Instead, they indicate the completion status of the
  278.    request.  There are three fundamental responses: success (OK), error
  279.  
  280.  
  281.  
  282. Crispin                                                         [Page 5]
  283.  
  284. Internet Draft                  IMAP2bis              September 30, 1993
  285.  
  286.  
  287.    (NO), request faulty or not understood (BAD).  The effect of a
  288.    command can not be considered complete until a command response with
  289.    a tag matching the command is received from the server.
  290.  
  291.    It is not required that a server process a command to completion
  292.    before beginning processing of the next command, except when the
  293.    processing of the previous command may affect the results of the next
  294.    command by changing the state of the current mailbox.  This has
  295.    certain other effects; for example, this implies that an EXPUNGE
  296.    response can not be transmitted as part of a response to a command
  297.    that uses sequence numbers, because EXPUNGE results in message
  298.    numbers being changed.
  299.  
  300.    Client implementations should update their local cache of data with
  301.    any received unsolicited data, regardless of whether or not the
  302.    client expected that data.  Unlike command completion responses, data
  303.    are not necessarily associated with a specific command.  The tagged
  304.    command completion response signals that the client cache is now
  305.    updated with the results of the corresponding command.
  306.  
  307.    If authentication has not yet been completed, it must now be done via
  308.    the LOGIN command before any access to data is permitted.  The only
  309.    permitted commands before successful authentication are LOGIN, NOOP,
  310.    and LOGOUT.  See the section below on authentication.
  311.  
  312.    Once authenticated, the client must send a mailbox selection command
  313.    to access the desired mailbox; no mailbox is selected by default.
  314.    Mailbox names are implementation dependent.  However, the word
  315.    "INBOX" must be implemented to mean the primary or default mailbox
  316.    for this user, independent of any other server semantics.  It is
  317.    permitted for a server not to have an INBOX if there is no concept of
  318.    a primary or default mailbox for this user.  The name "INBOX" MUST
  319.    NOT be used for any other purpose.
  320.  
  321.    On a successful selection, the server will send a list of valid
  322.    flags, number of messages, and number of messages arrived since last
  323.    access for this mailbox as unsolicited data, followed by an OK
  324.    response.  The client may close access to this mailbox and access a
  325.    different one with another selection command.
  326.  
  327.    Several flags are predefined in IMAP2bis.  All IMAP2bis flags begin
  328.    with a backslash ("\") character.  Servers MUST, at a minimum,
  329.    support all the predefined flags in this specification.  In addition,
  330.    a server may also have some implementation-defined per-mailbox flags
  331.    (called, for historical reasons, "keywords") that do not begin with
  332.    backslash.  Clients should use the information from the server's
  333.    FLAGS response at message selection to determine what flags the
  334.    server supports.
  335.  
  336.  
  337.  
  338. Crispin                                                         [Page 6]
  339.  
  340. Internet Draft                  IMAP2bis              September 30, 1993
  341.  
  342.  
  343.    The client requests mailbox data with FETCH commands, and receives it
  344.    via the unsolicited data mechanism.  Three major categories of
  345.    mailbox data exist.
  346.  
  347.    The first category is data that are associated with a message as an
  348.    entity in the mailbox.  There are now four such items of data: the
  349.    "internal date", the "RFC 822 size", the "flags", and the "unique
  350.    id".  The internal date is the date and time that the message was
  351.    placed in the mailbox.  The RFC 822 size is the size in octets of the
  352.    message, expressed as an RFC 822 text string.  The flags are a list
  353.    of status flags associated with the message.  The unique id is an
  354.    identifier that is guaranteed to refer to this message and to none
  355.    other in the mailbox and that, unlike IMAP2bis sequence numbers,
  356.    persists across sessions.
  357.  
  358.    The second category is data that describe the composition and
  359.    delivery information of a message; that is, information such as the
  360.    message sender, recipient lists, message-ID, subject, MIME structure,
  361.    etc.  This is the information that is stored in the RFC 822 and MIME
  362.    headers.  In IMAP2bis, the RFC 822 header information that may be
  363.    fetched is called the "envelope" (not to be confused with SMTP
  364.    envelopes).  Similarly, the MIME header information that may be
  365.    fetched is called the "body".  A client can use the parsed envelope
  366.    and body and not worry about having to do its own RFC 822 or MIME
  367.    parsing.
  368.  
  369.    The third category is textual data, some of which are intended for
  370.    direct human viewing.  IMAP2bis defines six such items:
  371.    RFC822.HEADER, RFC822.HEADER.LINES, RFC822.HEADER.LINES.NOT,
  372.    RFC822.TEXT, RFC822, and MIME body parts.  It is possible to fetch an
  373.    individual MIME body part of a message without fetching any other
  374.    data associated with the message.
  375.  
  376.    A simple client can "FETCH RFC822" to get the entire message without
  377.    any processing.  A more advanced client might fetch some combination
  378.    of the first and second categories of data for use as a presentation
  379.    menu.  Then, when the user wishes to read a particular message, it
  380.    will fetch the appropriate texts.
  381.  
  382.    Data structures in IMAP2bis are represented as an S-expression list
  383.    similar to that used in the Lisp programming language.  An S-
  384.    expression consists of a sequence of data items delimited by space
  385.    and bounded at each end by parentheses.  An S-expression may itself
  386.    contain other S-expressions, using parentheses to indicate nesting.
  387.    S-expression syntax was chosen because it provides a concise and
  388.    precise means of expressing nested data (e.g. MIME structures).
  389.  
  390.    The client can alter certain data with a STORE command.  As an
  391.  
  392.  
  393.  
  394. Crispin                                                         [Page 7]
  395.  
  396. Internet Draft                  IMAP2bis              September 30, 1993
  397.  
  398.  
  399.    example, a message is deleted from a mailbox by setting the \DELETED
  400.    flag with a STORE command.
  401.  
  402.    Other client operations that can be done to a mailbox include copying
  403.    messages to other mailboxes, permanently removing deleted messages,
  404.    checking for updated mailbox state, and searching for messages that
  405.    match certain criteria.  It is also possible to select a different
  406.    mailbox, create a new mailbox, rename an existing mailbox, or delete
  407.    an existing mailbox.
  408.  
  409.    The client should end the session with the LOGOUT command.  The
  410.    server returns a "BYE" followed by an "OK", at which point both the
  411.    client and the server close the connection.  If the client closes the
  412.    network connection without a LOGOUT command, the server should do its
  413.    normal logout procedures without attempting any further interaction
  414.    with the client.
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450. Crispin                                                         [Page 8]
  451.  
  452. Internet Draft                  IMAP2bis              September 30, 1993
  453.  
  454.  
  455. Authentication
  456.  
  457.    Pre-authentication is only possible when the connection to the
  458.    IMAP2bis service is made through some link protocol that provides its
  459.    own authentication mechanism.  It is not used with a TCP connection
  460.    to port 143.
  461.  
  462.    An example of pre-authentication is the BSD "RSH" protocol, that
  463.    provides authentication through a "trusted host" facility.  Another
  464.    example would be a manual invocation of an IMAP2bis server from a
  465.    logged-in timesharing job.
  466.  
  467.    A pre-authenticated IMAP2bis server should recognize that
  468.    authentication has already happened, and enter the post-login state.
  469.    In its greeting message, it should use the unsolicited response
  470.    "PREAUTH" instead of "OK" to indicate that external authentication
  471.    has taken place.
  472.  
  473.    This is an example of a pre-authentication scenario.  In this and all
  474.    other examples in this document, S: indicates server dialog and C:
  475.    indicates client dialog.
  476.  
  477.            S: * PREAUTH IMAP2bis Server pre-authenticated as user "Smith"
  478.            C: A001 SELECT INBOX
  479.            S: * FLAGS (\Answered \Flagged \Deleted \Seen)
  480.            S: * 19 EXISTS
  481.            S: * 2 RECENT
  482.            S: A001 OK SELECT complete
  483.  
  484.    A connection that is not pre-authenticated is constrained to using
  485.    the LOGIN command for establishing authentication.  Authentication
  486.    via the LOGIN command is with either a user name and password pair,
  487.    or with an user identifier and Kerberos authenticator.  See the
  488.    description of the LOGIN command for more details.
  489.  
  490.    Servers may allow non-authenticated access to certain mailboxes or
  491.    bulletin boards.  The convention is to use a LOGIN command with the
  492.    userid "anonymous".  A password is still required.  It is
  493.    implementation-dependent what requirements, if any, are placed on the
  494.    password and what access restrictions are placed on anonymous users.
  495.  
  496.    Implementations are NOT required to support pre-authentication,
  497.    Kerberos authentication, or the anonymous convention.
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506. Crispin                                                         [Page 9]
  507.  
  508. Internet Draft                  IMAP2bis              September 30, 1993
  509.  
  510.  
  511. Definitions of Commands and Responses
  512.  
  513.      Summary of Defined Commands and Responses
  514.  
  515.        Commands                            ||  Responses
  516.        --------                            ||  -------
  517.        tag NOOP                            ||  tag OK response_text
  518.        tag LOGIN user password             ||  tag NO response_text
  519.        tag LOGOUT                          ||  tag BAD response_text
  520.        tag CREATE mailbox                  ||  * PREAUTH response_text
  521.        tag DELETE mailbox                  ||  * OK response_text
  522.        tag RENAME old_mailbox new_mailbox  ||  * NO response_text
  523.        tag FIND MAILBOXES pattern          ||  * BAD response_text
  524.        tag FIND ALL.MAILBOXES pattern      ||  * BYE response_text
  525.        tag FIND BBOARDS pattern            ||  * MAILBOX mstring
  526.        tag FIND ALL.BBOARDS pattern        ||  * BBOARD mstring
  527.        tag SUBSCRIBE MAILBOX mailbox       ||  * SEARCH 1#number
  528.        tag UNSUBSCRIBE MAILBOX mailbox     ||  * FLAGS flag_list
  529.        tag SUBSCRIBE BBOARD mailbox        ||  * number EXISTS
  530.        tag UNSUBSCRIBE BBOARD mailbox      ||  * number RECENT
  531.        tag SELECT mailbox                  ||  * number EXPUNGE
  532.        tag EXAMINE mailbox                 ||  * number FETCH data
  533.        tag BBOARD mailbox                  ||  * number COPY
  534.        tag CHECK                           ||  * number STORE data
  535.        tag EXPUNGE                         ||  + text
  536.        tag COPY sequence mailbox           ||
  537.        tag APPEND mailbox 0#flag literal   ||
  538.        tag FETCH sequence data             ||
  539.        tag PARTIAL msgno data start count  ||
  540.        tag STORE sequence data value       ||
  541.        tag UID AFTER uniqueid              ||
  542.        tag UID COPY sequence mailbox       ||
  543.        tag UID FETCH sequence data         ||
  544.        tag UID STORE sequence data value   ||
  545.        tag SEARCH search_program           ||
  546.        tag x_command arguments             ||
  547.  
  548.    Note: there is no pairing between commands and responses on the same
  549.    line.  Any command may result in any number (including none at all)
  550.    of any of responses beginning with "*" (referred to as "unsolicited
  551.    data"), followed by one tagged response.
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562. Crispin                                                        [Page 10]
  563.  
  564. Internet Draft                  IMAP2bis              September 30, 1993
  565.  
  566.  
  567. Commands
  568.  
  569.    If, during the execution of any command, the server observes that the
  570.    mailbox size has changed, the server should output an unsolicited
  571.    EXISTS and RECENT response reflecting the changed size to alert the
  572.    client.  Similarly, any observed change in message status should
  573.    cause an unsolicited FETCH response with the new flag data.
  574.  
  575.  
  576.    tag NOOP
  577.  
  578.       The NOOP command returns an OK to the client.  By itself, it does
  579.       nothing else.  However, since any command can return a status
  580.       update as unsolicited data, this command can be used to poll for
  581.       new mail or for message status updates.
  582.  
  583.       Another possible use of this command is for the client to "ping"
  584.       the server so that the client and server know that each other are
  585.       still alive.  This is useful with servers that have an inactivity
  586.       autologout timer.
  587.  
  588.  
  589.    tag LOGIN user password
  590.  
  591.       The LOGIN command identifies the user to the server and carries
  592.       the password authenticating this user.  This information is used
  593.       by the server to control access to the mailboxes.
  594.  
  595.       EXAMPLE:  a001 LOGIN SMITH SESAME
  596.       logs in as user SMITH with password SESAME.
  597.  
  598.       If a server supports authentication via Kerberos, it may accept
  599.       the string "@KERBEROS:" followed by the hexadecimal representation
  600.       of a Kerberos authenticator.
  601.  
  602.       EXAMPLE: The following is a Kerberos login scenario (note that the
  603.       line breaks in the sample authenticator are for editorial clarity
  604.       and are not in a real authenticator):
  605.  
  606.          S: * OK Kerberos IMAP2bis Server
  607.          C: a001 LOGIN smith @KERBEROS:040700414e445245572e434d552e4544550
  608.             038202c868f3890b377fc8266acc1bedb96b80d3fa76489898e74cd1c952dc
  609.             4003ea3428f29f1c470016cf5adc22f939e6deff2747254c1815d5b0b90d4c
  610.             5a2cba21eb0abe32f9acbf568d751bf4cc13f5ba4e6d82c638a8b5421
  611.          S: a001 OK [df84a4cb8323454f] Login OK via Kerberos
  612.  
  613.       The token in the brackets in the OK response is the Kerberos
  614.       authentication response, encrypted with the session key in network
  615.  
  616.  
  617.  
  618. Crispin                                                        [Page 11]
  619.  
  620. Internet Draft                  IMAP2bis              September 30, 1993
  621.  
  622.  
  623.       byte order and an incremented checksum as in the usual Kerberos
  624.       procedure.
  625.  
  626.  
  627.    tag LOGOUT
  628.  
  629.       The LOGOUT command informs the server that the client is done with
  630.       the session.  The server should send an unsolicited BYE response
  631.       before the (tagged) OK response, and then close the network
  632.       connection.
  633.  
  634.  
  635.    Mailbox manipulation commands: CREATE, DELETE, RENAME
  636.  
  637.    These commands permit the manipulation of entire mailboxes.
  638.  
  639.       tag CREATE mailbox
  640.  
  641.          The CREATE command creates a mailbox with the given name.  This
  642.          command returns an OK response only if a new mailbox with that
  643.          name has been created.  It is an error to attempt to create a
  644.          mailbox with a name that refers to an extant mailbox.  Any
  645.          error in creation will return a NO response.
  646.  
  647.          Creating INBOX is not permitted.  If there is a primary or
  648.          default mailbox for this user, it MUST exist and be called
  649.          INBOX.
  650.  
  651.  
  652.       tag DELETE mailbox
  653.  
  654.          The DELETE command deletes a mailbox with the given name.  This
  655.          command returns an OK response only if a mailbox with that name
  656.          has been deleted.  It is an error to attempt to delete a
  657.          mailbox name that does not exist.  Any error in deletion will
  658.          return a NO response.
  659.  
  660.          A server SHOULD NOT attempt to test that a mailbox is empty
  661.          before permitting deletion; this would prevent the deletion of
  662.          a mailbox that for some reason can not be opened or expunged,
  663.          leaving to possible denial of service problems.  Any such
  664.          checking should be left to the discretion of the client.
  665.  
  666.          Deleting INBOX is not permitted.
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674. Crispin                                                        [Page 12]
  675.  
  676. Internet Draft                  IMAP2bis              September 30, 1993
  677.  
  678.  
  679.       tag RENAME old_mailbox new_mailbox
  680.  
  681.          The RENAME command changes the name of a mailbox.  This command
  682.          returns an OK response only if a mailbox with the old name
  683.          exists and has been successfully renamed to the new name.  It
  684.          is an error to attempt to rename with an old mailbox name that
  685.          does not exist or a new mailbox name that already exists.  Any
  686.          error in renaming will return a NO response.
  687.  
  688.          Renaming INBOX is permitted.  A new, empty INBOX is created in
  689.          its place.
  690.  
  691.  
  692.    FIND commands
  693.  
  694.    The FIND commands return some set of unsolicited MAILBOX or BBOARD
  695.    replies, depending on the type of FIND, that have as their value a
  696.    single mailbox name.
  697.  
  698.    Three wildcard characters are defined in the pattern argument.  "*"
  699.    specifies any number (including zero) characters may match at this
  700.    position.  "%" and "?"  specify a single character may match at this
  701.    position.  For example, FOO*BAR will match FOOBAR, FOOD.ON.THE.BAR
  702.    and FOO.BAR, whereas FOO%BAR and FOO?BAR match only FOO.BAR.  "*"
  703.    will match all mailboxes.
  704.  
  705.  
  706.       tag FIND MAILBOXES pattern
  707.  
  708.          The FIND MAILBOXES command accepts as an argument a pattern
  709.          (including wildcards) that specifies some set of mailbox names
  710.          that the user has declared as being "active" or "subscribed".
  711.          The exact meaning of this is implementation-dependent, since
  712.          the concept of a set of "active" or "subscribed" mailboxes that
  713.          is preserved across sessions may not be meaningful for a
  714.          particular server or server implementation.  If the SUBSCRIBE
  715.          MAILBOX and UNSUBSCRIBE MAILBOX commands are implemented then
  716.          this command returns the list manipulated by those commands.
  717.  
  718.          EXAMPLE:  C: A002 FIND MAILBOXES *
  719.                    S: * MAILBOX FOOBAR
  720.                    S: * MAILBOX GENERAL
  721.                    S: A002 OK FIND completed
  722.  
  723.  
  724.       tag FIND ALL.MAILBOXES pattern
  725.  
  726.          The FIND ALL.MAILBOXES command is similar to FIND MAILBOXES;
  727.  
  728.  
  729.  
  730. Crispin                                                        [Page 13]
  731.  
  732. Internet Draft                  IMAP2bis              September 30, 1993
  733.  
  734.  
  735.          however, it should return a complete list of all mailboxes
  736.          available to the user.  Data are returned as in FIND MAILBOXES.
  737.  
  738.          The special name INBOX is included in the output from FIND
  739.          ALL.MAILBOXES unless INBOX is not supported by this server or
  740.          for this user.  The criteria for omitting INBOX is whether
  741.          SELECT INBOX will return failure; it is not relevant whether
  742.          the user's real INBOX resides on this or some other server.
  743.          FIND MAILBOXES and SUBSCRIBE MAILBOX provide a mechanism for
  744.          the user to identify that this is his or her real INBOX.
  745.  
  746.          FIND ALL.MAILBOXES must, at least, return all the mailbox names
  747.          that are returned by FIND MAILBOXES.
  748.  
  749.          The exact meaning of this is implementation-dependent, since
  750.          the concept of a bounded or deterministic set of "mailboxes
  751.          available to the user" may not be meaningful for a particular
  752.          server or server implementation.
  753.  
  754.  
  755.       tag FIND BBOARDS pattern
  756.  
  757.          The FIND BBOARDS command accepts as an argument a pattern that
  758.          specifies some set of bulletin board names that the user has
  759.          declared as being "active" or "subscribed".  Wildcards are
  760.          permitted as in FIND MAILBOXES.
  761.  
  762.          The FIND BBOARDS command will return some set of unsolicited
  763.          BBOARD replies that have as their value a single bulletin board
  764.          name.
  765.  
  766.          EXAMPLE:  C: A002 FIND BBOARDS *
  767.                    S: * BBOARD FOOBAR
  768.                    S: * BBOARD GENERAL
  769.                    S: A002 OK FIND completed
  770.  
  771.          The exact meaning of this is implementation-dependent, since
  772.          the concept of a set of "active" or "subscribed" bboards that
  773.          is preserved across sessions may not be meaningful for a
  774.          particular server or server implementation.  If the SUBSCRIBE
  775.          BBOARD and UNSUBSCRIBE BBOARD commands are implemented then
  776.          this command returns the list manipulated by those commands.
  777.  
  778.  
  779.       tag FIND ALL.BBOARDS pattern
  780.  
  781.          The FIND ALL.BBOARDS command is similar to FIND BBOARDS;
  782.          however, it should return a complete list of all bulletin
  783.  
  784.  
  785.  
  786. Crispin                                                        [Page 14]
  787.  
  788. Internet Draft                  IMAP2bis              September 30, 1993
  789.  
  790.  
  791.          boards available to the user.  Data are returned as in FIND
  792.          BBOARDS.
  793.  
  794.          FIND ALL.BBOARDS must, at least, return all the bboard names
  795.          that are returned by FIND BBOARDS.
  796.  
  797.          The exact meaning of this is implementation-dependent, since
  798.          the concept of a bounded or deterministic set of "bboards
  799.          available to the user" may not be meaningful for a particular
  800.          server or server implementation.
  801.  
  802.  
  803.    Subscription commands
  804.  
  805.    These commands permit the manipulation of mailbox or bulletin board
  806.    subscriptions.  Subscription status should be preserved between
  807.    sessions.
  808.  
  809.  
  810.       tag SUBSCRIBE MAILBOX mailbox
  811.  
  812.          The SUBSCRIBE MAILBOX command adds the specified mailbox name
  813.          to the list of "active" or "subscribed" mailboxes as returned
  814.          by the FIND MAILBOXES command.  This command returns an OK
  815.          response only if the subscription is successful.
  816.  
  817.  
  818.       tag UNSUBSCRIBE MAILBOX mailbox
  819.  
  820.          The UNSUBSCRIBE MAILBOX command removes the specified mailbox
  821.          name from the list of "active" or "subscribed" mailboxes as
  822.          returned by the FIND MAILBOXES command.  This command returns
  823.          an OK response only if the unsubscription is successful.
  824.  
  825.  
  826.       tag SUBSCRIBE BBOARD bboard
  827.  
  828.          The SUBSCRIBE BBOARD command adds the specified mailbox name to
  829.          the list of "active" or "subscribed" bulletin boards as
  830.          returned by the FIND BBOARDS command.  This command returns an
  831.          OK response only if the subscription is successful.
  832.  
  833.  
  834.       tag UNSUBSCRIBE BBOARD bboard
  835.  
  836.          The UNSUBSCRIBE BBOARD command removes the specified mailbox
  837.          name from the list of "active" or "subscribed" bulletin boards
  838.          as returned by the FIND BBOARDS command.  This command returns
  839.  
  840.  
  841.  
  842. Crispin                                                        [Page 15]
  843.  
  844. Internet Draft                  IMAP2bis              September 30, 1993
  845.  
  846.  
  847.          an OK response only if the unsubscription is successful.
  848.  
  849.  
  850.    tag SELECT mailbox
  851.  
  852.       This command selects a particular mailbox.  The server must check
  853.       that the user is permitted read access to this mailbox.  Before
  854.       returning an OK to the client, the server must send the following
  855.       unsolicited data to the client:
  856.          FLAGS        mailbox's defined flags
  857.          <n> EXISTS   the number of messages in the mailbox
  858.          <n> RECENT   the number of messages added to the mailbox since the
  859.                       previous time this mailbox was read
  860.       to define the initial state of the mailbox at the client.  If it
  861.       can not be determined which messages were added since the previous
  862.       time a mailbox was read, then all messages SHOULD be considered
  863.       recent.  An example of this is if no "last read" time information
  864.       is available or a read-only mailbox that does not permit a change
  865.       of "last read" time.
  866.  
  867.       Multiple selection commands are permitted in a session.  The
  868.       previous mailbox is automatically deselected when a new selection
  869.       is made.  If concurrent access to multiple mailboxes is desired,
  870.       the client should open additional sessions as needed.
  871.  
  872.       The mailbox name INBOX is a special name reserved to mean "the
  873.       primary mailbox for this user on this server".  The format of
  874.       other mailbox names is implementation dependent.
  875.  
  876.       The text of an OK response to the SELECT command should begin with
  877.       either "[READ-ONLY]" or "[READ-WRITE]" to show the mailbox's
  878.       access status.
  879.  
  880.  
  881.    tag EXAMINE mailbox
  882.  
  883.       The EXAMINE command is similar to SELECT, and returns the same
  884.       output; however, the selected mailbox is identified as read-only
  885.       and no changes are permitted to this mailbox.  EXAMINE has the
  886.       same mailbox namespace as SELECT.
  887.  
  888.  
  889.    tag BBOARD mailbox
  890.  
  891.       The BBOARD command is similar to SELECT, and returns the same
  892.       output.  Its argument is a shared mailbox (bulletin board) name
  893.       instead of an ordinary mailbox.  There is no requirement that the
  894.       namespace for BBOARD be the same as that for SELECT and EXAMINE.
  895.  
  896.  
  897.  
  898. Crispin                                                        [Page 16]
  899.  
  900. Internet Draft                  IMAP2bis              September 30, 1993
  901.  
  902.  
  903.       BBOARD also differs from EXAMINE in that it may allow changes
  904.       (e.g. marking a message as seen or deleted) to a mailbox; the
  905.       exact handling of this is implementation dependent.
  906.  
  907.  
  908.    tag CHECK
  909.  
  910.       The CHECK command requests a checkpoint of the mailbox.  CHECK may
  911.       cause an operation that may take a non-instantaneous amount of
  912.       real-time to complete.  The exact meaning of a checkpoint is
  913.       implementation-dependent.  Possible interpretations include
  914.       forcing an update of the server's disk of all changes made to the
  915.       selected mailbox, rescanning of the entire mailbox, etc.  If an
  916.       implementation has no such considerations, CHECK should be
  917.       equivalent to NOOP.
  918.  
  919.       CHECK should NOT be used to poll for new mail; new mail checking
  920.       happens implicitly as part of every command.  NOOP should be used
  921.       for any new mail polling.  CHECK should NOT be used to get the
  922.       current size of the mailbox; there is no guarantee that CHECK will
  923.       cause an EXISTS or RECENT unsolicited response.
  924.  
  925.  
  926.    tag EXPUNGE
  927.  
  928.       The EXPUNGE command permanently removes all messages with the
  929.       \DELETED flag set from the currently selected mailbox.  Before
  930.       returning an OK to the client, for each message that is removed,
  931.       an unsolicited EXPUNGE response is sent.  The message number for
  932.       each successive message in the mailbox is immediately decremented
  933.       by 1; this means that if the last 5 messages in a 9-message mail
  934.       file are expunged the client will receive 5 unsolicited EXPUNGE
  935.       responses for message 5.
  936.  
  937.  
  938.    tag COPY sequence mailbox
  939.  
  940.       The COPY command copies the specified message(s) to the specified
  941.       destination mailbox.  The flags of the message(s) SHOULD be
  942.       preserved in the copy.
  943.  
  944.       If the destination mailbox does not exist, a server SHOULD return
  945.       an error.  It SHOULD NOT automatically create the mailbox.  Unless
  946.       it is certain that the destination mailbox can not be created, the
  947.       server MUST send the special information token "[TRYCREATE]" as
  948.       the prefix of the text of the tagged NO response.  This gives a
  949.       hint to the client that it can attempt a CREATE command and retry
  950.       the COPY if the CREATE is successful.
  951.  
  952.  
  953.  
  954. Crispin                                                        [Page 17]
  955.  
  956. Internet Draft                  IMAP2bis              September 30, 1993
  957.  
  958.  
  959.       If the COPY command is unsuccessful for any reason, IMAP2bis
  960.       compliant server implementations MUST restore the destination
  961.       mailbox its prior state before the COPY attempt.
  962.  
  963.       EXAMPLE:  A003 COPY 2:4 MEETING
  964.       copies messages 2, 3, and 4 to mailbox "MEETING".
  965.  
  966.  
  967.    tag APPEND mailbox 0#flag literal
  968.  
  969.       The APPEND command appends the literal argument as a new message
  970.       in the specified destination mailbox.  This argument is in the
  971.       format of an RFC 822 message.  If any flags are specified, those
  972.       flags SHOULD be set in the resulting message.  If the append is
  973.       unsuccessful for any reason the mailbox must be restored to its
  974.       prior state before the APPEND attempt; no partial appending is
  975.       permitted.  If the mailbox is currently selected, the normal new
  976.       mail actions should occur.
  977.  
  978.       Server implementations SHOULD return a NO response if the length
  979.       of the literal is zero.
  980.  
  981.       If the destination mailbox does not exist, a server MUST return an
  982.       error, and MUST NOT automatically create the mailbox.  Unless it
  983.       is certain that the destination mailbox can not be created, the
  984.       server MUST send the special information token "[TRYCREATE]" as
  985.       the prefix of the text of the tagged NO response.  This gives a
  986.       hint to the client that it can attempt a CREATE command and retry
  987.       the APPEND if the CREATE is successful.
  988.  
  989.       Note that this functionality is unsuitable for message delivery,
  990.       because it does not provide a mechanism to transfer RFC 821 (SMTP)
  991.       envelope information.
  992.  
  993.  
  994.    tag FETCH sequence data
  995.  
  996.       The FETCH command retrieves data associated with a message in the
  997.       mailbox.  The data items to be fetched may be either a single atom
  998.       or an S-expression list.  The currently defined data items that
  999.       can be fetched are:
  1000.  
  1001.       ALL             Macro equivalent to:
  1002.                       (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
  1003.  
  1004.       BODY            Non-extensible form of BODYSTRUCTURE.
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010. Crispin                                                        [Page 18]
  1011.  
  1012. Internet Draft                  IMAP2bis              September 30, 1993
  1013.  
  1014.  
  1015.       BODY[section]   The text of a particular body section.  The
  1016.                       section specification is a set of one or more
  1017.                       part numbers delimited by periods.
  1018.  
  1019.                       Single-part messages only have a part 1.
  1020.  
  1021.                       Multipart messages are assigned consecutive
  1022.                       part numbers, as they occur in the message.
  1023.                       If a particular part is of type message or multipart,
  1024.                       its parts must be indicated by a period followed by
  1025.                       the part number within that nested multipart part.
  1026.                       It is not permitted to fetch a multipart part
  1027.                       itself, only its individual members.
  1028.  
  1029.                       A part of type MESSAGE and subtype RFC822 also
  1030.                       has nested parts.  These are the parts of the
  1031.                       MESSAGE part's body.  Nested part 0 of a part of
  1032.                       type MESSAGE and subtype RFC822 is the RFC 822
  1033.                       header of the message.
  1034.  
  1035.                       Every message has at least one part.
  1036.  
  1037.                       EXAMPLE: Here is a complex message with its
  1038.                       associated section specifications.
  1039.                            1   TEXT/PLAIN
  1040.                            2   APPLICATION/OCTET-STREAM
  1041.                            3   MESSAGE/RFC822
  1042.                            3.0   (RFC 822 header of the message)
  1043.                            3.1   TEXT/PLAIN
  1044.                            3.2   APPLICATION/OCTET-STREAM
  1045.                                MULTIPART/MIXED
  1046.                            4.1   IMAGE/GIF
  1047.                            4.2   MESSAGE/RFC822
  1048.                            4.2.0   (RFC 822 header of the message)
  1049.                            4.2.1   TEXT/PLAIN
  1050.                                    MULTIPART/ALTERNATIVE
  1051.                            4.2.2.1  TEXT/PLAIN
  1052.                            4.2.2.2  TEXT/RICHTEXT
  1053.                       Note that there is no section specification for
  1054.                       the Multi-part parts (no section 4 or 4.2.2).
  1055.  
  1056.                       The \SEEN flag is implicitly set; if this causes
  1057.                       the flags to change they should be included as
  1058.                       part of the fetch results.
  1059.  
  1060.       BODYSTRUCTURE   The MIME body structure of the message.  The
  1061.                       body is computed by the server by parsing the
  1062.                       MIME header lines.
  1063.  
  1064.  
  1065.  
  1066. Crispin                                                        [Page 19]
  1067.  
  1068. Internet Draft                  IMAP2bis              September 30, 1993
  1069.  
  1070.  
  1071.       ENVELOPE        The envelope of the message.  The envelope is
  1072.                       computed by the server by parsing the RFC 822
  1073.                       header into the component parts, defaulting
  1074.                       various fields as necessary.
  1075.  
  1076.       FAST            Macro equivalent to:
  1077.                       (FLAGS INTERNALDATE RFC822.SIZE)
  1078.  
  1079.       FLAGS           The flags that are set for this message.
  1080.  
  1081.       FULL            Macro equivalent to:
  1082.                       (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)
  1083.  
  1084.       INTERNALDATE    The date and time the message was written to
  1085.                       the mailbox.
  1086.  
  1087.       RFC822          The message in RFC 822 format.  The \SEEN
  1088.                       flag is implicitly set; if this causes the
  1089.                       flags to change they should be included as
  1090.                       part of the fetch results.  This is the
  1091.                       concatenation of RFC822.HEADER and RFC822.TEXT.
  1092.  
  1093.       RFC822.HEADER   The RFC 822 format header of the message as
  1094.                       stored on the server including the delimiting
  1095.                       blank line between the header and the body.
  1096.  
  1097.       RFC822.HEADER.LINES header_line_list
  1098.                       All header lines (including continuation lines)
  1099.                       of the RFC 822 format header of the message
  1100.                       with a field-name (as defined in RFC 822) that
  1101.                       matches any of the strings in header_line_list.
  1102.                       The matching is case-independent but otherwise
  1103.                       exact.
  1104.  
  1105.       RFC822.HEADER.LINES.NOT header_line_list
  1106.                       All header lines (including continuation lines)
  1107.                       of the RFC 822 format header of the message
  1108.                       with a field-name (as defined in RFC 822) that
  1109.                       does not match any of the strings in
  1110.                       header_line_list.  The matching is
  1111.                       case-independent but otherwise exact.
  1112.  
  1113.       RFC822.SIZE     The number of characters in the message as
  1114.                       expressed in RFC 822 format.
  1115.  
  1116.       RFC822.TEXT     The text body of the message, omitting the
  1117.                       RFC 822 header.  The \SEEN flag is implicitly
  1118.                       set; if this causes the flags to change they
  1119.  
  1120.  
  1121.  
  1122. Crispin                                                        [Page 20]
  1123.  
  1124. Internet Draft                  IMAP2bis              September 30, 1993
  1125.  
  1126.  
  1127.                       should be included as part of the fetch results.
  1128.  
  1129.       UID             The unique identifier for the message.
  1130.  
  1131.       EXAMPLES:
  1132.  
  1133.       A003 FETCH 2:4 ALL
  1134.          fetches the flags, internal date, RFC 822 size, and envelope
  1135.          for messages 2, 3, and 4.
  1136.  
  1137.       A004 FETCH 3 RFC822
  1138.          fetches the RFC 822 representation for message 3.
  1139.  
  1140.       A005 FETCH 4 (FLAGS RFC822.HEADER)
  1141.          fetches the flags and RFC 822 format header for message 4.
  1142.  
  1143.  
  1144.    tag PARTIAL msgno data start_octet octet_count
  1145.  
  1146.       The PARTIAL command is equivalent to the associated FETCH command,
  1147.       with the added functionality that only the specified number of
  1148.       octets, beginning at the specified starting octet, are returned.
  1149.       Note that only a single message can be fetched at a time.  The
  1150.       first octet of a message, and hence the minimum for the starting
  1151.       octet, is octet 1.
  1152.  
  1153.       The following FETCH items are valid data for PARTIAL: RFC822,
  1154.       RFC822.HEADER, RFC822.TEXT, and BODY[section].
  1155.  
  1156.       Any partial fetch that attempts to read beyond the end of the text
  1157.       is truncated as appropriate.  If the starting octet is beyond the
  1158.       end of the text, an empty string is returned.
  1159.  
  1160.       The data are returned with the FETCH response.  There is no
  1161.       indication of the range of the partial data in this response; thus
  1162.       it is generally not possible to implement caching with PARTIAL
  1163.       data.  It is also not possible to stream multiple PARTIAL commands
  1164.       of the same data item without processing and synchronizing at each
  1165.       step, since each PARTIAL fetch of data replaces any prior
  1166.       (PARTIAL) FETCH of the data.
  1167.  
  1168.       Note that when partial fetching it is possible to break in the
  1169.       middle of a line or a critical sequence such as a BASE64 quadruple
  1170.       or QUOTED-PRINTABLE shift.  Implementations using partial fetching
  1171.       should keep this in mind.  There is no requirement that partial
  1172.       fetches follow any sequence; so if it turns out that a partial
  1173.       fetch of octets 1 through 10000 breaks in an awkward place, it is
  1174.       permitted to continue with a partial fetch of 9987 through 19987,
  1175.  
  1176.  
  1177.  
  1178. Crispin                                                        [Page 21]
  1179.  
  1180. Internet Draft                  IMAP2bis              September 30, 1993
  1181.  
  1182.  
  1183.       etc.
  1184.  
  1185.       The handling of the \SEEN flag is the same as with the FETCH
  1186.       command.
  1187.  
  1188.  
  1189.    tag STORE sequence data value
  1190.  
  1191.       The STORE command alters data associated with a message in the
  1192.       mailbox.  The currently defined data items that can be stored are:
  1193.  
  1194.          FLAGS           Replace the flags for the message with the
  1195.                          argument (in flag list format).
  1196.  
  1197.          +FLAGS          Add the flags in the argument to the
  1198.                          message's flag list.
  1199.  
  1200.          -FLAGS          Remove the flags in the argument from the
  1201.                          message's flag list.
  1202.  
  1203.       EXAMPLE:  A003 STORE 2:4 +FLAGS (\DELETED)
  1204.       marks messages 2, 3, and 4 for deletion.
  1205.  
  1206.  
  1207.    UID commands
  1208.  
  1209.    These commands use unique identifiers instead of message numbers in
  1210.    their arguments to reference a particular message or range of
  1211.    messages.  The unique identifier of a message is guaranteed not to
  1212.    refer to any other message in the mailbox.  Unlike IMAP2bis sequence
  1213.    numbers, unique identifiers persist across sessions.
  1214.  
  1215.    Sequence ranges are permitted; note however that there is no
  1216.    guarantee that unique identifiers be contiguous.  A non-existent
  1217.    unique identifier within a sequence range is ignored without any
  1218.    error message generated.
  1219.  
  1220.    Because of the potential for ambiguity, the UID command does not
  1221.    change responses.  That is, the number after the "*" in an
  1222.    unsolicited FETCH response is a message number, not a unique
  1223.    identifier.  However, servers MUST implicitly include UID as part of
  1224.    any FETCH response caused by a UID command, regardless of whether UID
  1225.    was specified.
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234. Crispin                                                        [Page 22]
  1235.  
  1236. Internet Draft                  IMAP2bis              September 30, 1993
  1237.  
  1238.  
  1239.    EXAMPLE:  C: A003 UID FETCH 4827313:4828442 FLAGS
  1240.              S: * 23 FETCH (FLAGS (\SEEN) UID 4827313)
  1241.              S: * 24 FETCH (FLAGS (\SEEN) UID 4827943)
  1242.              S: * 25 FETCH (FLAGS (\SEEN) UID 4828442)
  1243.              S: A003 UID FETCH completed
  1244.  
  1245.  
  1246.       tag UID AFTER uniqueid
  1247.  
  1248.          The UID AFTER command determines what unique identifiers exist
  1249.          that are greater than the specified unique identifier.  It
  1250.          returns unsolicited FETCH responses for each such message.
  1251.  
  1252.          For example, if the specified unique identifier refers to
  1253.          message 572 in a mailbox with 613 messages, the results
  1254.          returned are equivalent to doing "FETCH 573:613 UID".
  1255.  
  1256.  
  1257.       tag UID COPY sequence mailbox
  1258.  
  1259.          The UID COPY command is identical to the COPY command, with the
  1260.          exception that the numbers used in the sequence are unique
  1261.          identifiers instead of message numbers.
  1262.  
  1263.  
  1264.       tag UID FETCH sequence data
  1265.  
  1266.          The UID FETCH command is identical to the FETCH command, with
  1267.          the exception that the numbers used in the sequence are unique
  1268.          identifiers instead of message numbers.
  1269.  
  1270.  
  1271.       tag UID STORE sequence data value
  1272.  
  1273.          The UID STORE command is identical to the STORE command, with
  1274.          the exception that the numbers used in the sequence are unique
  1275.          identifiers instead of message numbers.
  1276.  
  1277.  
  1278.    tag SEARCH search_criteria
  1279.  
  1280.       The SEARCH command searches the mailbox for messages that match
  1281.       the given set of criteria.  The unsolicited SEARCH <1#number>
  1282.       response from the server is a list of messages that express the
  1283.       intersection (AND function) of all the messages that match that
  1284.       criteria.  For example,
  1285.               A003 SEARCH DELETED FROM "SMITH" SINCE 1-OCT-87
  1286.       returns the message numbers for all deleted messages from Smith
  1287.  
  1288.  
  1289.  
  1290. Crispin                                                        [Page 23]
  1291.  
  1292. Internet Draft                  IMAP2bis              September 30, 1993
  1293.  
  1294.  
  1295.       that were placed in the mail file since October 1, 1987.
  1296.  
  1297.       In all search criteria that use strings, a message matches the
  1298.       criteria if the string is a substring of the field.  The matching
  1299.       is case-independent except as noted below.
  1300.  
  1301.       The server may interpret an RFC 1522 format string to express text
  1302.       in a character set other than US-ASCII.  The criteria matches if
  1303.       the RFC 1522 interpreted string matches an interpreted substring
  1304.       (MIME or RFC 1522 as appropriate) of the field.
  1305.  
  1306.       A server implementation may omit case-independent matching on RFC
  1307.       1522 strings.
  1308.  
  1309.       The currently defined search criteria are:
  1310.  
  1311.       ALL             All messages in the mailbox; the default
  1312.                       initial criterion for ANDing.
  1313.  
  1314.       ANSWERED        Messages with the \ANSWERED flag set.
  1315.  
  1316.       BCC istring     Messages that contain the specified string
  1317.                       in the envelope's BCC field.
  1318.  
  1319.       BEFORE date     Messages whose internal date is earlier than
  1320.                       the specified date.
  1321.  
  1322.       BODY istring    Messages that contain the specified string
  1323.                       in the body of the message.
  1324.  
  1325.       CC istring      Messages that contain the specified string
  1326.                       in the envelope's CC field.
  1327.  
  1328.       DELETED         Messages with the \DELETED flag set.
  1329.  
  1330.       FLAGGED         Messages with the \FLAGGED flag set.
  1331.  
  1332.       FROM istring    Messages that contain the specified string
  1333.                       in the envelope's FROM field.
  1334.  
  1335.       KEYWORD flag    Messages with the specified flag set.
  1336.  
  1337.       NEW             Messages that have the \RECENT flag set but
  1338.                       not the \SEEN flag.  This is functionally
  1339.                       equivalent to "RECENT UNSEEN".
  1340.  
  1341.       OLD             Messages that do not have the \RECENT flag
  1342.                       set.
  1343.  
  1344.  
  1345.  
  1346. Crispin                                                        [Page 24]
  1347.  
  1348. Internet Draft                  IMAP2bis              September 30, 1993
  1349.  
  1350.  
  1351.       ON date         Messages whose internal date is within the
  1352.                       specified date.
  1353.  
  1354.       RECENT          Messages that have the \RECENT flag set.
  1355.  
  1356.       SEEN            Messages that have the \SEEN flag set.
  1357.  
  1358.       SINCE date      Messages whose internal date is later than
  1359.                       the specified date.
  1360.  
  1361.       SUBJECT istring Messages that contain the specified string
  1362.                       in the envelope's SUBJECT field.
  1363.  
  1364.       TEXT istring    Messages that contain the specified string.
  1365.  
  1366.       TO istring      Messages that contain the specified string in
  1367.                       the envelope's TO field.
  1368.  
  1369.       UNANSWERED      Messages that do not have the \ANSWERED flag
  1370.                       set.
  1371.  
  1372.       UNDELETED       Messages that do not have the \DELETED flag
  1373.                       set.
  1374.  
  1375.       UNFLAGGED       Messages that do not have the \FLAGGED flag
  1376.                       set.
  1377.  
  1378.       UNKEYWORD flag  Messages that do not have the specified flag
  1379.                       set.
  1380.  
  1381.       UNSEEN          Messages that do not have the \SEEN flag set.
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402. Crispin                                                        [Page 25]
  1403.  
  1404. Internet Draft                  IMAP2bis              September 30, 1993
  1405.  
  1406.  
  1407. Responses
  1408.  
  1409.    The first group of responses complete a request, and indicate whether
  1410.    the command was successful.  The response text is a line of human
  1411.    readable text, optionally prefixed by an atom inside square brackets
  1412.    that conveys a special information token between cooperating servers
  1413.    and clients.
  1414.  
  1415.    The currently defined special information tokens are:
  1416.  
  1417.       PARSE           An error occurred in parsing the RFC 822 or MIME
  1418.                       headers of a message in the mailbox.
  1419.  
  1420.       READ-ONLY       The mailbox is open read-only, or its access while
  1421.                       open has changed from read-write to read-only.
  1422.  
  1423.       READ-WRITE      The mailbox is open read-write, or its access while
  1424.                       open has changed from read-only to read-write.
  1425.  
  1426.       TRYCREATE       An APPEND or COPY attempt failed because the target
  1427.                       mailbox does not exist.  The server sends this as a
  1428.                       hint to the client that the operation would probably
  1429.                       succeed if the mailbox is first created by means of
  1430.                       the CREATE command.
  1431.  
  1432.       UNSEEN          Followed by a decimal number, indicates the number
  1433.                       of the first unread message.  This is intended to be
  1434.                       used with certain bboard formats to assist the user
  1435.                       in finding the first unread message in those cases
  1436.                       where "unread" and "recent" are separate concepts.
  1437.  
  1438.       hex string      A hexadecimal string is returned as a special
  1439.                       information token to represent a Kerberos return
  1440.                       authenticator.  This only occurs in response to a
  1441.                       LOGIN command that uses Kerberos authentication.
  1442.  
  1443.    Other special information tokens defined by particular client or
  1444.    server implementations should be prefixed with an "X" until they are
  1445.    added to a revision of this protocol.
  1446.  
  1447.  
  1448.    tag OK response_text
  1449.  
  1450.       This response identifies successful completion of the command with
  1451.       that tag.  The response text may be useful in a protocol telemetry
  1452.       log for debugging purposes.
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458. Crispin                                                        [Page 26]
  1459.  
  1460. Internet Draft                  IMAP2bis              September 30, 1993
  1461.  
  1462.  
  1463.    tag NO response_text
  1464.  
  1465.       This response identifies unsuccessful completion of the command
  1466.       with that tag.  The text is a line of human-readable text that
  1467.       probably should be displayed to the user in an error report by the
  1468.       client.
  1469.  
  1470.  
  1471.    tag BAD response_text
  1472.  
  1473.       This response identifies faulty protocol received from the client;
  1474.       The text is a line of human-readable text that should be recorded
  1475.       in any telemetry as part of a bug report to the maintainer of the
  1476.       client.
  1477.  
  1478.  
  1479.    The second group of responses convey human-readable information.  The
  1480.    response text is a line of human readable text, optionally prefixed
  1481.    by an atom inside square brackets that conveys special information
  1482.    between cooperating servers and clients.
  1483.  
  1484.  
  1485.    * PREAUTH response_text
  1486.  
  1487.       This response is one of three possible greetings at session
  1488.       startup.  It indicates that the session has already been
  1489.       authenticated by external means and thus no LOGIN command is
  1490.       needed.
  1491.  
  1492.  
  1493.    * OK response_text
  1494.  
  1495.       This response identifies an information message from the server.
  1496.       It does not indicate completion of any particular request, nor is
  1497.       it necessarily related to any request.  The text is a line of
  1498.       human-readable text that should be presented to the user as an
  1499.       information message.
  1500.  
  1501.       This response is also one of three possible greetings at session
  1502.       startup.  It indicates that the session is not yet authenticated
  1503.       and that a LOGIN command is needed.
  1504.  
  1505.  
  1506.    * NO response_text
  1507.  
  1508.       This response identifies a warning message from the server.  It
  1509.       does not indicate completion of any request, nor is it necessarily
  1510.       related to any request.  The text is a line of human-readable text
  1511.  
  1512.  
  1513.  
  1514. Crispin                                                        [Page 27]
  1515.  
  1516. Internet Draft                  IMAP2bis              September 30, 1993
  1517.  
  1518.  
  1519.       that should be presented to the user as a warning of improper
  1520.       operation.
  1521.  
  1522.  
  1523.    * BAD response_text
  1524.  
  1525.       This response identifies a serious error message from the server.
  1526.       It does not indicate completion of any request, nor is it
  1527.       necessarily related to any request.  It may also indicate a faulty
  1528.       command from the client in which a tag could not be parsed.  The
  1529.       text is a line of human-readable text that should be presented to
  1530.       the user as a serious or possibly fatal error.
  1531.  
  1532.  
  1533.    * BYE text
  1534.  
  1535.       This response identifies that the server is about to close the
  1536.       connection.  The text is a line of human-readable text that should
  1537.       be displayed to the user in a status report by the client.  This
  1538.       may be sent as part of a normal logout sequence, or as a panic
  1539.       shutdown announcement by the server.  It is also used by some
  1540.       servers as an announcement of an inactivity autologout.
  1541.  
  1542.       This response is also one of three possible greetings at session
  1543.       startup.  It indicates that the server is not willing to accept a
  1544.       session from this client.
  1545.  
  1546.  
  1547.    The third group of responses convey data about the mailbox or
  1548.    messages inside the mailbox.  This is how message data are
  1549.    transmitted from the server to the client.
  1550.  
  1551.  
  1552.    * MAILBOX mstring
  1553.  
  1554.       This response occurs as a result of a FIND command for MAILBOXES
  1555.       and ALL.MAILBOXES.  The string is a mailbox name that matches the
  1556.       pattern in the command.
  1557.  
  1558.  
  1559.    * BBOARD mstring
  1560.  
  1561.       This response occurs as a result of a FIND command for BBOARDS and
  1562.       ALL.BBOARDS.  The string is a bulletin board name that matches the
  1563.       pattern in the command.
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570. Crispin                                                        [Page 28]
  1571.  
  1572. Internet Draft                  IMAP2bis              September 30, 1993
  1573.  
  1574.  
  1575.    * SEARCH number(s)
  1576.  
  1577.       This response occurs as a result of a SEARCH command.  The
  1578.       number(s) refer to those messages that match the search criteria.
  1579.       Each number is delimited by a space, e.g., "SEARCH 2 3 6".
  1580.  
  1581.  
  1582.    * FLAGS flag_list
  1583.  
  1584.       This response generally occurs as a result of a selection command
  1585.       (SELECT, BBOARD, and EXAMINE).  The flag list are the list of
  1586.       flags (at a minimum, the system-defined flags) that are applicable
  1587.       for this mailbox.  Flags other than the system flags are a
  1588.       function of the server implementation.
  1589.  
  1590.  
  1591.    * number message_data
  1592.  
  1593.       This response occurs as a result of any command when a mailbox is
  1594.       selected.  The message_data is one of the following:
  1595.  
  1596.  
  1597.       EXISTS  The number of messages in the mailbox.
  1598.  
  1599.  
  1600.       RECENT  The number of messages that have arrived since the
  1601.               previous time this mailbox was read.
  1602.  
  1603.  
  1604.       EXPUNGE The specified message number has been permanently
  1605.               removed from the mailbox, and the next message in the
  1606.               mailbox (if any) becomes that message number.
  1607.  
  1608.               An unsolicited EXPUNGE response MUST NOT be sent except
  1609.               while responding to a request other than FETCH, STORE,
  1610.               or SEARCH.  All references to message numbers sent after
  1611.               an unsolicited EXPUNGE response are adjusted to reflect
  1612.               the effect of the expunge.
  1613.  
  1614.                  Discussion: a potential ambiguity exists with
  1615.                  the FETCH, STORE, and SEARCH requests if the
  1616.                  server is permitted to send unsolicited EXPUNGE
  1617.                  responses.  This is because these requests can be
  1618.                  streamed.  If two successive FETCH requests are
  1619.                  streamed, and if during the time of the processing
  1620.                  of the first request there is an expunge response,
  1621.                  then the sequence of the second request is no
  1622.                  longer valid.
  1623.  
  1624.  
  1625.  
  1626. Crispin                                                        [Page 29]
  1627.  
  1628. Internet Draft                  IMAP2bis              September 30, 1993
  1629.  
  1630.  
  1631.       FETCH data
  1632.               This is the principal means that data about a message
  1633.               are returned to the client.  The data are in an
  1634.               S-expression form, and consists of a sequence of pairs
  1635.               of data item name and their values.  The current data
  1636.               items are:
  1637.  
  1638.          BODY          Similar to BODYSTRUCTURE, but without the extension
  1639.                        data.
  1640.  
  1641.          BODY[section] A string expressing the body contents of the
  1642.                        specified section.  The string should be
  1643.                        interpreted by the client according to the
  1644.                        content transfer encoding, body type, and subtype.
  1645.  
  1646.                        Note that non-textual data are transfer encoded;
  1647.                        therefore, the string is likely to be 7-bit
  1648.                        US-ASCII.  This is NOT necessarily the byte size
  1649.                        or character set of the interpreted result.
  1650.  
  1651.          BODYSTRUCTURE An S-expression format list that describes the
  1652.                        body of a message.  The body is computed by the
  1653.                        server by parsing the RFC 822 header and body into
  1654.                        the component parts, defaulting various fields
  1655.                        as necessary.
  1656.  
  1657.                        Multiple parts are indicated by S-expression
  1658.                        nesting.  Instead of a body type as the first element
  1659.                        of the list there is a nested body.  The second
  1660.                        element of the list is the multipart subtype (mixed,
  1661.                        digest, parallel, alternative, etc.).
  1662.  
  1663.                        Extension data follows the multipart subtype.
  1664.                        Extension data is never returned with the older
  1665.                        BODY fetch, but may be returned with a BODYSTRUCTURE
  1666.                        fetch.  Extension data, if present, must be in the
  1667.                        defined order.
  1668.  
  1669.                        No multipart extension data is currently defined.
  1670.  
  1671.                        Any subsequent data is extension data, not yet defined
  1672.                        in this version of the protocol.  Such extension data
  1673.                        consist of zero or more NILs, strings, numbers,
  1674.                        and/or potentially nested lists of such data.  Clients
  1675.                        which do a BODYSTRUCTURE fetch MUST be prepared to
  1676.                        accept such extension data.  Servers MUST NOT send
  1677.                        such extension data until it has been defined by a
  1678.                        future version of the protocol.
  1679.  
  1680.  
  1681.  
  1682. Crispin                                                        [Page 30]
  1683.  
  1684. Internet Draft                  IMAP2bis              September 30, 1993
  1685.  
  1686.  
  1687.                        The basic fields of a non-multipart body part are in
  1688.                        the following order:
  1689.                          body type - a string giving the content type name
  1690.                            as defined in MIME
  1691.                          body subtype - a string giving the content subtype
  1692.                            name as defined in MIME
  1693.                          body parameter list - an S-expression list of
  1694.                            attribute/value pairs [e.g. (foo bar baz rag)
  1695.                            where "bar" is the value of "foo" and "rag" is
  1696.                            the value of "baz"] as defined in MIME.
  1697.                          body id - a string giving the content id as
  1698.                            defined in MIME.
  1699.                          body description - a string giving the content
  1700.                            description as defined in MIME.
  1701.                          body encoding - a string giving the content
  1702.                            transfer encoding as defined in MIME.
  1703.                          body size - a number giving the size of the
  1704.                            body in octets.  Note that this size is the
  1705.                            size in its transfer encoding and not the
  1706.                            resulting size after any decoding.
  1707.  
  1708.                        A body type of type MESSAGE and subtype RFC822
  1709.                        contains, immediately after the basic fields,
  1710.                        the envelope of the encapsulated message, its
  1711.                        body structure, and its size in text lines.
  1712.  
  1713.                        A body type of type TEXT contains, immediately
  1714.                        after the basic fields, the size of the body
  1715.                        in text lines.  Note that this size is the size
  1716.                        in its transfer encoding and not the resulting
  1717.                        size after any decoding.
  1718.  
  1719.                        Extension data follows the basic fields and the
  1720.                        type-specific fields listed above.  Extension data
  1721.                        is never returned with the older BODY fetch, but
  1722.                        may be returned with a BODYSTRUCTURE fetch.
  1723.                        Extension data, if present, must be in the defined
  1724.                        order.
  1725.  
  1726.                        The extension data of a non-multipart body part are
  1727.                        in the following order:
  1728.                          body MD5 - a string giving the content MD5 value
  1729.                            as defined in MIME
  1730.  
  1731.                        Any subsequent extension data are not yet defined
  1732.                        in this version of the protocol, and would be in the
  1733.                        form described above under multipart extension data.
  1734.  
  1735.  
  1736.  
  1737.  
  1738. Crispin                                                        [Page 31]
  1739.  
  1740. Internet Draft                  IMAP2bis              September 30, 1993
  1741.  
  1742.  
  1743.          ENVELOPE      An S-expression format list that describes the
  1744.                        envelope of a message.  The envelope is computed
  1745.                        by the server by parsing the RFC 822 header into
  1746.                        the component parts, defaulting various fields
  1747.                        as necessary.
  1748.  
  1749.                        The fields of the envelope are in the following
  1750.                        order: date, subject, from, sender, reply-to, to,
  1751.                        cc, bcc, in-reply-to, and message-id.  The date,
  1752.                        subject, in-reply-to, and message-id fields are
  1753.                        strings.  The from, sender, reply-to, to, cc,
  1754.                        and bcc fields are lists of addresses.
  1755.  
  1756.                        An address is an S-expression format list that
  1757.                        describes an electronic mail address.  The fields
  1758.                        of an address are in the following order:
  1759.                        personal name, source-route (a.k.a. the
  1760.                        at-domain-list in SMTP), mailbox name, and
  1761.                        host name.
  1762.  
  1763.                        RFC 822 group syntax is indicated by a special
  1764.                        form of address in which the host name field is
  1765.                        NIL.  If the mailbox name field is also NIL, this
  1766.                        is an end of group marker (semi-colon in RFC 822
  1767.                        syntax).  If the mailbox name field is non-NIL,
  1768.                        this is a start of group marker, and the mailbox
  1769.                        name field holds the group name phrase.
  1770.  
  1771.                        Any field of an envelope or address that is
  1772.                        not applicable is presented as the atom NIL.
  1773.                        Note that the server must default the reply-to
  1774.                        and sender fields from the from field; a client is
  1775.                        not expected to know to do this.
  1776.  
  1777.          FLAGS         An S-expression format list of flags that are set
  1778.                        for this message.  This may include the following
  1779.                        system flags:
  1780.  
  1781.                        \SEEN         Message has been read
  1782.                        \ANSWERED     Message has been answered
  1783.                        \FLAGGED      Message is "flagged" for
  1784.                                       urgent/special attention
  1785.                        \DELETED      Message is "deleted" for
  1786.                                       removal by later EXPUNGE
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794. Crispin                                                        [Page 32]
  1795.  
  1796. Internet Draft                  IMAP2bis              September 30, 1993
  1797.  
  1798.  
  1799.                        as well as the following special flag:
  1800.  
  1801.                        \RECENT       Message arrived since the
  1802.                                       previous time this mailbox
  1803.                                       was read
  1804.  
  1805.          INTERNALDATE  A string containing the date and time the
  1806.                        message was written to the mailbox.
  1807.  
  1808.          RFC822        A string expressing the message in RFC 822
  1809.                        format.
  1810.  
  1811.          RFC822.HEADER A string expressing the RFC 822 format header
  1812.                        of the message, including the delimiting
  1813.                        blank line between the header and the body.
  1814.                        This is used for the FETCH data items
  1815.                        RFC822.HEADER, RFC822.HEADER.LINES, and
  1816.                        RFC822.HEADER.LINES.NOT (note that a blank
  1817.                        line is always included regardless of header
  1818.                        line restrictions).
  1819.  
  1820.          RFC822.SIZE   A number indicating the number of
  1821.                        characters in the message as expressed
  1822.                        in RFC 822 format.
  1823.  
  1824.          RFC822.TEXT   A string expressing the text body of the
  1825.                        message, omitting the RFC 822 header.
  1826.  
  1827.          UID           A number expressing the unique identifier
  1828.                        of the message.
  1829.  
  1830.  
  1831.       COPY    Obsolete.  New server implementations MUST NOT transmit
  1832.               this response.  Client implementations SHOULD ignore
  1833.               this response (not report an error).
  1834.  
  1835.  
  1836.       STORE data
  1837.               Obsolete and functionally equivalent to FETCH.  New
  1838.               server implementations MUST NOT transmit this response.
  1839.               Client implementations SHOULD treat this response as
  1840.               equivalent to the FETCH response.
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850. Crispin                                                        [Page 33]
  1851.  
  1852. Internet Draft                  IMAP2bis              September 30, 1993
  1853.  
  1854.  
  1855.    The final group of responses contains a single, special purpose
  1856.    response.
  1857.  
  1858.    + response_text
  1859.  
  1860.       This response identifies that the server is ready to accept the
  1861.       text of a literal from the client.  The text of this response is a
  1862.       line of human-readable text of the server's choosing (it is
  1863.       generally never seen by a client's human user).
  1864.  
  1865.       The purpose of this command is to solve a synchronization problem
  1866.       that can occur if a string in a command is a literal.  This may
  1867.       occur when logging in (if the password contains "funny"
  1868.       characters), and always occurs when using the APPEND command,
  1869.       since a message consists of multiple lines.
  1870.  
  1871.       Normally, a command from the client is a single text line.  If the
  1872.       server detects an error in the command, it can simply discard the
  1873.       remainder of the line.  It cannot do this for commands that
  1874.       contain literals, since a literal can be an arbitrarily long
  1875.       amount of text, and the server may not even be expecting a
  1876.       literal.  This mechanism is provided so the client knows not to
  1877.       send a literal until the server expects it, preserving
  1878.       client/server synchronization.
  1879.  
  1880.       No such synchronization protection is provided for literals sent
  1881.       from the server to the client.  Any synchronization problems in
  1882.       this direction would be caused by a bug in the client or server.
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906. Crispin                                                        [Page 34]
  1907.  
  1908. Internet Draft                  IMAP2bis              September 30, 1993
  1909.  
  1910.  
  1911. Sample IMAP2bis session
  1912.  
  1913.    The following is a transcript of an IMAP2bis session.  A long line in
  1914.    this sample is broken for editorial clarity.
  1915.  
  1916.    S:   * OK IMAP2bis Service 7.2(62) at Thu, 29 Jul 1993 21:34:23 -0700 (PDT)
  1917.    C:   a001 login mrc secret
  1918.    S:   a001 OK LOGIN completed
  1919.    C:   a002 select inbox
  1920.    S:   * 18 EXISTS
  1921.    S:   * FLAGS (\Answered \Flagged \Deleted \Seen)
  1922.    S:   * 0 RECENT
  1923.    S:   a002 OK [READ-WRITE] SELECT completed
  1924.    S:   a003 fetch 12 full
  1925.    S:   * 12 FETCH (FLAGS (\Seen) INTERNALDATE "14-Jul-1993 02:44:25 -0700"
  1926.          RFC822.SIZE 4282 ENVELOPE ("Wed, 14 Jul 1993 02:23:25 -0700 (PDT)"
  1927.          "IMAP2bis WG mtg summary and minutes" (("Terry Gray" NIL "gray"
  1928.          "cac.washington.edu")) ((NIL NIL "owner-imap" "cac.washington.edu"))
  1929.          (("Terry Gray" NIL "gray" "cac.washington.edu")) ((NIL NIL "imap"
  1930.          "cac.washington.edu")) ((NIL NIL "minutes" "CNRI.Reston.VA.US")
  1931.          ("John C Klensin" NIL "KLENSIN" "INFOODS.MIT.EDU")("Erik Huizer"
  1932.          NIL "Erik.Huizer" "SURFnet.nl")) NIL NIL
  1933.          "<Pine.3.84.9307140123.B27397-0100000@shiva2.cac.washington.edu>")
  1934.           BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 92))
  1935.    S:    a003 OK FETCH completed
  1936.    C:    a004 fetch 12 rfc822.header
  1937.    S:    * 12 FETCH (RFC822.HEADER {485}
  1938.    S:    Date: Wed, 14 Jul 1993 02:23:25 -0700 (PDT)
  1939.    S:    From: Terry Gray <gray@cac.washington.edu>
  1940.    S:    Reply-To: Terry Gray <gray@cac.washington.edu>
  1941.    S:    Subject: IMAP2bis WG mtg summary and minutes
  1942.    S:    To: imap@cac.washington.edu
  1943.    S:    Cc: minutes@CNRI.Reston.VA.US,
  1944.    S:            John C Klensin <KLENSIN@INFOODS.MIT.EDU>,
  1945.    S:            Erik Huizer <Erik.Huizer@SURFnet.nl>
  1946.    S:    Message-Id:
  1947.    S:     <Pine.3.84.9307140123.B27397-0100000@shiva2.cac.washington.edu>
  1948.    S:    Mime-Version: 1.0
  1949.    S:    Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  1950.    S:
  1951.    S:    )
  1952.    S:    a004 OK FETCH completed
  1953.    C:    a005 store 12 +flags \deleted
  1954.    S:    * 12 FETCH (FLAGS (\Seen \Deleted))
  1955.    S:    a005 OK +FLAGS completed
  1956.    C:    a006 logout
  1957.    S:    * BYE IMAP2bis server terminating connection
  1958.    S:    a006 OK LOGOUT completed
  1959.  
  1960.  
  1961.  
  1962. Crispin                                                        [Page 35]
  1963.  
  1964. Internet Draft                  IMAP2bis              September 30, 1993
  1965.  
  1966.  
  1967. Design Discussion
  1968.  
  1969.    IMAP2bis is a textual protocol.  The use of MIME encoding in IMAP2bis
  1970.    makes it possible to support 8-bit textual and binary mail.
  1971.  
  1972.    IMAP2bis implementations MAY transmit 8-bit or multi-octet characters
  1973.    in literals, but should do so only when the character set is
  1974.    identified.  For example, 8-bit characters are specifically permitted
  1975.    in MIME body parts (fetching BODY[section]) of type TEXT.  8-bit
  1976.    characters are also permitted in the argument to APPEND.
  1977.  
  1978.    Servers MUST NOT transmit 8-bit characters in RFC822.HEADER fetch
  1979.    results.  Servers MUST NOT transmit 8-bit characters in RFC822.TEXT
  1980.    (and by extension RFC822) fetch results, unless there are MIME data
  1981.    in the message that identify the character sets of all 8-bit data.
  1982.  
  1983.    Because 8-bit characters are permitted in the argument to APPEND, a
  1984.    server that is unable to preserve 8-bit data properly MUST be able to
  1985.    reversibly convert 8-bit APPEND data to 7-bit using MIME.
  1986.  
  1987.    Although a BINARY body encoding is defined, IMAP2bis does not permit
  1988.    unencoded binary strings.  A "binary string" is any string with NUL
  1989.    characters; a string with an excessive amount of CTL characters may
  1990.    also be considered to be binary.  The mixing of unencoded binary in
  1991.    the same stream as textual commands would make the protocol more
  1992.    vulnerable to synchronization problems.  Implementations MUST encode
  1993.    binary data into BASE64 before transmitting it with IMAP2bis.
  1994.  
  1995.    When operating in the online model, an IMAP2bis client should
  1996.    maintain a local cache of data from the mailbox.  This cache is an
  1997.    incomplete model of the mailbox, and at startup is generally empty.
  1998.    As the client processes all unsolicited data, it updates the cache
  1999.    based on this data.  When a tagged response arrives, the client's
  2000.    cache has been updated from the associated request.
  2001.  
  2002.    Note that a server can send data that the client did not request,
  2003.    such as mailbox size or flag updates.  A server MUST send mailbox
  2004.    size updates automatically while processing a command.  A server
  2005.    SHOULD send message flag updates automatically, without requiring the
  2006.    client to request such updates explicitly.
  2007.  
  2008.    Regardless of what implementation decisions a client may take on
  2009.    caching, a client MUST record EXISTS and RECENT updates and MUST NOT
  2010.    assume that a CHECK or NOOP command will return EXISTS or RECENT
  2011.    information.
  2012.  
  2013.    Although it is permitted for a server to send an unsolicited response
  2014.    while there is no command in progress, this practice SHOULD NOT be
  2015.  
  2016.  
  2017.  
  2018. Crispin                                                        [Page 36]
  2019.  
  2020. Internet Draft                  IMAP2bis              September 30, 1993
  2021.  
  2022.  
  2023.    followed because of flow control considerations.  It can cause an
  2024.    incautious implementation to deadlock.  A deadlock is avoided if
  2025.    either of the following conditions are true: (1) except for the
  2026.    greeting, the server never sends responses while there is no command
  2027.    in progress; (2) the server process is capable of reading commands
  2028.    while sending data.  The latter condition generally requires a either
  2029.    a multi-threading server implementation or use of a polling facility
  2030.    and non-blocking I/O.
  2031.  
  2032.    If a server has an inactivity autologout timer, that timer MUST be of
  2033.    at least 30 minutes' duration.  The receipt of a NOOP command from
  2034.    the client during that interval should suffice to reset the
  2035.    autologout timer.  Periodic transmission of a NOOP from the client
  2036.    during periods of inactivity also has the benefit of avoiding the
  2037.    possible deadlock noted above.
  2038.  
  2039.    It is frequently asked why there is no message posting function in
  2040.    IMAP2bis.  Message posting is orthogonal to the scope of a mail
  2041.    access protocol and detracts from its primary focus.  SMTP (RFC 821)
  2042.    provides the minimal functionality needed for message posting without
  2043.    losing valuable capabilities (such as blind carbon copies).  Any
  2044.    message posting function in IMAP2bis would need, at a minimum, to
  2045.    provide equivalent functionality.
  2046.  
  2047.    At the time of the writing of this document, an extensive set of
  2048.    extensions to SMTP is in the Internet standards process.  Should
  2049.    those extensions become an Internet Standard it would be necessary to
  2050.    revise IMAP2bis again to provide corresponding capabilities, were a
  2051.    message posting facility to be included in IMAP2bis.  In other words,
  2052.    a duplication of effort would be required each time a change is made
  2053.    to message transport technology.
  2054.  
  2055.    Another undesirable aspect of message posting in IMAP2bis occurs when
  2056.    a remote server is used.  It is unlikely that a client would support
  2057.    multiple means of posting a message.  It adds excessive size and
  2058.    complexity that can not be afforded, particularly on smaller
  2059.    machines.  It also can lead to poor performance.  Consider a client
  2060.    connecting to an IMAP2bis server over an interactive satellite link
  2061.    to a foreign country.  A local message posting (SMTP) server is
  2062.    available that uses a lower-cost batched link.  Here, it would be
  2063.    wasteful to use the interactive link for posting.
  2064.  
  2065.    Message posting to IMAP2bis has been suggested as a means of
  2066.    authenticating postings.  The problem is that access authentication
  2067.    credentials are not necessarily the same as posting authentication
  2068.    credentials.  At some sites, the disclosure of a portion of access
  2069.    authentication credentials in a mail message (as a "From" or "Sender"
  2070.    address) may be a serious security breach of greater significance
  2071.  
  2072.  
  2073.  
  2074. Crispin                                                        [Page 37]
  2075.  
  2076. Internet Draft                  IMAP2bis              September 30, 1993
  2077.  
  2078.  
  2079.    than forged mail.
  2080.  
  2081.    The Internet message transport infrastructure has no concept of
  2082.    authentication credentials, and neither authentication syntax nor
  2083.    semantics are transferred within a message.  As a result, any attempt
  2084.    at authenticating a message via posting authentication is completely
  2085.    ineffective once the message leaves the authenticating server; any
  2086.    indication of authentication in the message can easily be reproduced
  2087.    further down the line.  Public-key based message authentication
  2088.    systems such as Privacy Enhanced Mail are now under development to
  2089.    address this problem.
  2090.  
  2091.    IMAP2bis does not address problems with multiple IMAP2bis servers at
  2092.    a single site, access control lists, and mobility of client
  2093.    configuration and address book information.  These and other issues
  2094.    are being considered for a companion protocol.
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130. Crispin                                                        [Page 38]
  2131.  
  2132. Internet Draft                  IMAP2bis              September 30, 1993
  2133.  
  2134.  
  2135. Formal Syntax
  2136.  
  2137.    The following syntax specification uses the augmented Backus-Naur
  2138.    Form (BNF) notation as specified in RFC 822 with one exception; the
  2139.    delimiter used with the "#" construct is a single space (SPACE) and
  2140.    not a comma.
  2141.  
  2142.    Except as noted otherwise, all alphabetic characters in the IMAP2bis
  2143.    protocol are case-insensitive.  For example, "LOGIN", "login" and
  2144.    "lOgIn" are all valid as the login command.
  2145.  
  2146.    Syntax marked as obsolete may be encountered with implementations
  2147.    written for an older version of this specification.  New
  2148.    implementations SHOULD accept obsolete syntax as input, but MUST NOT
  2149.    otherwise use it.
  2150.  
  2151.    address         ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox
  2152.                        SPACE addr_host ")"
  2153.  
  2154.    addr_adl        ::= nstring
  2155.  
  2156.    addr_host       ::= nstring
  2157.                        ;; NIL indicates RFC 822 group syntax
  2158.  
  2159.    addr_mailbox    ::= nstring
  2160.                        ;; NIL indicates end of RFC 822 group; if non-NIL
  2161.                        ;; and addr_host is NIL, holds RFC 822 group name
  2162.  
  2163.    addr_name       ::= nstring
  2164.  
  2165.    append          ::= "APPEND" SPACE mailbox [SPACE 1#flag] SPACE literal
  2166.  
  2167.    astring         ::= atom / string
  2168.  
  2169.    atom            ::= 1*<any CHAR except specials, SPACE, and CTLs>
  2170.  
  2171.    bboard          ::= "BBOARD" SPACE mailbox_bboard
  2172.  
  2173.    body            ::= "(" body_structure ")"
  2174.  
  2175.    body2           ::= "(" body2_structure ")"
  2176.  
  2177.    body2_extension ::= nstring / number / "(" 1#body2_extension ")"
  2178.                        ;; Future expansion.  Clients MUST accept body2
  2179.                        ;; extension fields.  Servers MUST NOT generate
  2180.                        ;; body2 extension fields.
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186. Crispin                                                        [Page 39]
  2187.  
  2188. Internet Draft                  IMAP2bis              September 30, 1993
  2189.  
  2190.  
  2191.    body2_md5       ::= nstring
  2192.                        ;; reserved for MD5 checksum
  2193.  
  2194.    body2_multipart ::= 1*body2 SPACE body_subtype [SPACE 1#body2_extension]
  2195.  
  2196.    body2_structure ::= body2_terminal / body2_multipart
  2197.  
  2198.    body2_terminal  ::= body_terminal SPACE body2_md5 [SPACE 1#body2_extension]
  2199.  
  2200.    body_basic      ::= body_type_basic SPACE body_subtype SPACE body_fields
  2201.  
  2202.    body_fields     ::= body_parameter SPACE body_id SPACE body_description
  2203.                        SPACE body_encoding SPACE body_size
  2204.  
  2205.    body_description::= nstring
  2206.  
  2207.    body_encoding   ::= <"> body_enc_def <"> / body_enc_other
  2208.  
  2209.    body_enc_def    ::= "7BIT" / "8BIT" / "BINARY" / "BASE64"/
  2210.                        "QUOTED-PRINTABLE"
  2211.  
  2212.    body_enc_other  ::= string
  2213.  
  2214.    body_id         ::= nstring
  2215.  
  2216.    body_msg        ::= body_msg_822 / body_msg_other
  2217.  
  2218.    body_msg_822    ::= body_type_msg SPACE body_subtyp_822 SPACE body_fields
  2219.                        SPACE envelope SPACE body SPACE body_size_lines
  2220.  
  2221.    body_msg_other  ::= body_type_msg SPACE body_subtype SPACE body_fields
  2222.                        ;; subtype MUST NOT be "RFC822"
  2223.  
  2224.    body_multipart  ::= 1*body SPACE body_subtype
  2225.  
  2226.    body_parameter  ::= nil / "(" 1#(string string) ")"
  2227.  
  2228.    body_section    ::= number / number "." body_section
  2229.  
  2230.    body_size       ::= number
  2231.                        ;; size in octets
  2232.  
  2233.    body_size_lines ::= number
  2234.  
  2235.    body_structure  ::= body_terminal / body_multipart
  2236.  
  2237.    body_subtype    ::= string
  2238.  
  2239.  
  2240.  
  2241.  
  2242. Crispin                                                        [Page 40]
  2243.  
  2244. Internet Draft                  IMAP2bis              September 30, 1993
  2245.  
  2246.  
  2247.    body_subtyp_822 ::= <"> "RFC822" <">
  2248.  
  2249.    body_terminal   ::= body_basic / body_msg / body_text
  2250.  
  2251.    body_text       ::= body_type_text SPACE body_subtype SPACE body_fields
  2252.                        SPACE body_size_lines
  2253.  
  2254.    body_type_basic ::= <"> ("APPLICATION" / "AUDIO" / "IMAGE" / "VIDEO") <"> /
  2255.                        string
  2256.  
  2257.    body_type_msg  ::= <"> "MESSAGE" <">
  2258.  
  2259.    body_type_text  ::= <"> "TEXT" <">
  2260.  
  2261.    CHAR            ::= <any 7-bit US-ASCII character except NUL, 0x01 - 0x7f>
  2262.  
  2263.    CHAR8           ::= <any 8-bit octet except NUL, 0x01 - 0xff>
  2264.  
  2265.    check           ::= "CHECK"
  2266.  
  2267.    copy            ::= "COPY" SPACE sequence SPACE mailbox
  2268.  
  2269.    CR              ::= <ASCII CR, carriage return, 0x0C>
  2270.  
  2271.    create          ::= create_real / create_check
  2272.  
  2273.    create_check    ::= "CREATE" SPACE "INBOX"
  2274.                        ;; returns a NO response (not BAD)
  2275.  
  2276.    create_real     ::= "CREATE" SPACE mailbox_other
  2277.  
  2278.    CRLF            ::= CR LF
  2279.  
  2280.    CTL             ::= <any ASCII control character and DEL, 0x00 - 0x1f, 0x7f>
  2281.  
  2282.    date            ::= date_new / date_old
  2283.  
  2284.    date_day        ::= 1*2DIGIT
  2285.                        ;; day of month
  2286.  
  2287.    date_month      ::= "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
  2288.                        "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
  2289.  
  2290.    date_new        ::= date_day "-" date_month "-" date_year
  2291.  
  2292.    date_old        ::= date_day "-" date_month "-" date_year_old
  2293.                        ;; Obsolete
  2294.  
  2295.  
  2296.  
  2297.  
  2298. Crispin                                                        [Page 41]
  2299.  
  2300. Internet Draft                  IMAP2bis              September 30, 1993
  2301.  
  2302.  
  2303.    date_year       ::= 4DIGIT / date_year_old
  2304.  
  2305.    date_year_old   ::= 2DIGIT
  2306.                        ;; Obsolete, (year - 1900)
  2307.  
  2308.    date_time       ::= date_time_new / date_time_old
  2309.  
  2310.    date_time_new   ::= date_new SPACE time SPACE zone
  2311.  
  2312.    date_time_old   ::= date_old SPACE time "-" zone_old
  2313.                        ;; Obsolete
  2314.  
  2315.    delete          ::= "DELETE" SPACE mailbox_other
  2316.  
  2317.    DIGIT           ::= <any ASCII decimal digit, 0x30 - 0x39>
  2318.  
  2319.    DIGIT_HEX       :: DIGIT / "a" / "b" / "c" / "d" / "e" / "f"
  2320.  
  2321.    envelope        ::= "(" env_date SPACE env_subject SPACE env_from SPACE
  2322.                        env_sender SPACE env_reply-to SPACE env_to SPACE
  2323.                        env_cc SPACE env_bcc SPACE env_in-reply-to SPACE
  2324.                        env_message-id ")"
  2325.  
  2326.    env_bcc         ::= nil / "(" 1*address ")"
  2327.  
  2328.    env_cc          ::= nil / "(" 1*address ")"
  2329.  
  2330.    env_date        ::= nstring
  2331.  
  2332.    env_from        ::= nil / "(" 1*address ")"
  2333.  
  2334.    env_in-reply-to ::= nstring
  2335.  
  2336.    env_message-id  ::= nstring
  2337.  
  2338.    env_reply-to    ::= nil / "(" 1*address ")"
  2339.  
  2340.    env_sender      ::= nil / "(" 1*address ")"
  2341.  
  2342.    env_subject     ::= nstring
  2343.  
  2344.    env_to          ::= nil / "(" 1*address ")"
  2345.  
  2346.    examine         ::= "EXAMINE" SPACE mailbox
  2347.  
  2348.    expunge         ::= "EXPUNGE"
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354. Crispin                                                        [Page 42]
  2355.  
  2356. Internet Draft                  IMAP2bis              September 30, 1993
  2357.  
  2358.  
  2359.    fetch           ::= "FETCH" SPACE sequence SPACE ("ALL" / "FULL" /
  2360.                        "FAST" / fetch_att / "(" 1#fetch_att ")")
  2361.  
  2362.    fetch_att       ::= fetch_att_other / fetch_att_text
  2363.  
  2364.    fetch_att_other ::= "BODY" / "BODYSTRUCTURE" / "ENVELOPE" / "FLAGS" /
  2365.                        "INTERNALDATE" / "RFC822.SIZE" / "UID"
  2366.  
  2367.    fetch_att_text  ::= "BODY[" body_section "]" / "RFC822" /
  2368.                        "RFC822.HEADER" /
  2369.                        "RFC822.HEADER.LINES" SPACE header_line_list /
  2370.                        "RFC822.HEADER.LINES.NOT" SPACE header_line_list /
  2371.                        "RFC822.TEXT"
  2372.  
  2373.    find            ::= find_mailbox / find_bboard
  2374.  
  2375.    find_bboard     ::= find_bboards / find_boards_all
  2376.  
  2377.    find_bboards    ::= "FIND" SPACE "BBOARDS" SPACE find_pattern
  2378.  
  2379.    find_bboards_all
  2380.                    ::= "FIND" SPACE "ALL.BBOARDS" SPACE find_pattern
  2381.  
  2382.    find_mailbox    ::= find_mailboxes / find_mailboxes_all
  2383.  
  2384.    find_mailboxes  ::= "FIND" SPACE "MAILBOXES" SPACE find_pattern
  2385.  
  2386.    find_mailboxes_all
  2387.                    ::= "FIND" SPACE "ALL.MAILBOXES" SPACE find_pattern
  2388.  
  2389.    find_pattern    ::= astring
  2390.                        ;; includes find_wildcards
  2391.  
  2392.    find_wildcards  ::= "%" / "?" / "*"
  2393.  
  2394.    flag            ::= user_flag / system_flag
  2395.  
  2396.    flag_list       ::= "(" 1#flag ")"
  2397.  
  2398.    flags           ::= 1#flag / flag_list
  2399.  
  2400.    greeting        ::= "*" SPACE (human_data / "PREAUTH" SPACE response_text)
  2401.  
  2402.    header_line     ::= astring
  2403.  
  2404.    header_line_list ::= "(" 1#header_line ")"
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410. Crispin                                                        [Page 43]
  2411.  
  2412. Internet Draft                  IMAP2bis              September 30, 1993
  2413.  
  2414.  
  2415.    human_data      ::= "OK" SPACE response_text / "NO" SPACE response_text /
  2416.                        "BAD" SPACE response_text / "BYE" SPACE response_text
  2417.  
  2418.    inbox           ::= "INBOX"
  2419.                        ;; case-independent, but SHOULD be upper-case
  2420.  
  2421.    istring         ::= astring
  2422.                        ;; possible RFC 1522 format data
  2423.  
  2424.    kerberos_authenticator
  2425.                    ::= 1*DIGIT_HEX
  2426.  
  2427.    kerberos_response
  2428.                    ::= 1*DIGIT_HEX
  2429.  
  2430.    LF              ::= <ASCII LF, line feed, 0x0A>
  2431.  
  2432.    literal         ::= "{" number "}" CRLF 1*CHAR8
  2433.                        ;; The number represents the number of CHAR8 octets.
  2434.  
  2435.    login           ::= "LOGIN" SPACE userid SPACE password
  2436.  
  2437.    logout          ::= "LOGOUT"
  2438.  
  2439.    mailbox         ::= inbox / mailbox_other
  2440.  
  2441.    mailbox_bboard  ::= astring
  2442.                        ;; May not be INBOX (in any case).  Should not
  2443.                        ;; include find_wildcards.  May be case-dependent
  2444.                        ;; as a function of server implementation.  May
  2445.                        ;; be a different namespace from mailbox_other.
  2446.  
  2447.    mailbox_other   ::= astring
  2448.                        ;; May not be INBOX (in any case).  Should not
  2449.                        ;; include find_wildcards.  May be case-dependent
  2450.                        ;; as a function of server implementation
  2451.  
  2452.    mailbox_data    ::= "MAILBOX" SPACE mstring / "BBOARD" SPACE mstring /
  2453.                         "SEARCH" SPACE 1#number / "FLAGS" SPACE flag_list
  2454.  
  2455.    message_data    ::= number SPACE (msg_exists / msg_recent / msg_expunge /
  2456.                        msg_fetch / msg_obsolete)
  2457.  
  2458.    msg_copy        ::= "COPY"
  2459.                        ;; Obsolete
  2460.  
  2461.    msg_exists      ::= "EXISTS"
  2462.  
  2463.  
  2464.  
  2465.  
  2466. Crispin                                                        [Page 44]
  2467.  
  2468. Internet Draft                  IMAP2bis              September 30, 1993
  2469.  
  2470.  
  2471.    msg_expunge     ::= "EXPUNGE"
  2472.  
  2473.    msg_fetch       ::= "FETCH" SPACE "(" 1#("BODY" SPACE body /
  2474.                        "BODYSTRUCTURE" SPACE body2 /
  2475.                        "BODY[" body_section "]" nstring /
  2476.                        "ENVELOPE" SPACE envelope /
  2477.                        "FLAGS" SPACE "(" 1#(recent_flag / flag) ")" /
  2478.                        "INTERNALDATE" SPACE date_time /
  2479.                        "RFC822" SPACE nstring /
  2480.                        "RFC822.HEADER" SPACE nstring /
  2481.                        "RFC822.SIZE" SPACE number /
  2482.                        "RFC822.TEXT" SPACE nstring /
  2483.                        "UID" SPACE uniqueid) ")"
  2484.  
  2485.    msg_obsolete    ::= msg_copy / msg_store
  2486.                        ;; Obsolete unsolicited data responses
  2487.  
  2488.    msg_recent      ::= "RECENT"
  2489.  
  2490.    msg_store       ::= "STORE" SPACE "(" 1#("FLAGS" SPACE
  2491.                        "(" 1#(recent_flag / flag) "))"
  2492.                        ;; Obsolete
  2493.  
  2494.    mstring         ::= text_line
  2495.                        ;; Represents a mailbox
  2496.  
  2497.    nil             ::= "NIL"
  2498.  
  2499.    noop            ::= "NOOP"
  2500.  
  2501.    nstring         ::= nil / string
  2502.  
  2503.    number          ::= 1*DIGIT
  2504.  
  2505.    partial         ::= "PARTIAL" SPACE number SPACE fetch_att_text SPACE
  2506.                        number SPACE number
  2507.  
  2508.    password        ::= astring / "@KERBEROS:" kerberos_authenticator
  2509.  
  2510.    QCHAR           ::= <any CHAR except qspecials, CR, and LF>
  2511.  
  2512.    qspecials       ::= <"> / "%" / "\"
  2513.  
  2514.    quoted_string   ::= <"> *QCHAR <">
  2515.  
  2516.    recent_flag     ::= "\RECENT"
  2517.  
  2518.    ready           ::= "+" SPACE response_text
  2519.  
  2520.  
  2521.  
  2522. Crispin                                                        [Page 45]
  2523.  
  2524. Internet Draft                  IMAP2bis              September 30, 1993
  2525.  
  2526.  
  2527.    rename          ::= "RENAME" SPACE mailbox SPACE mailbox_other
  2528.  
  2529.    request         ::= tag SPACE (request_auth / request_authed / request_open)
  2530.                        ;; modal based on state
  2531.  
  2532.    request_any     ::= noop / logout
  2533.                        ;; valid in all modes
  2534.  
  2535.    request_auth    ::= request_any / login
  2536.                        ;; valid only when in not authenticated mode
  2537.  
  2538.    request_authed  ::= request_any / create / delete / rename / find /
  2539.                        subscribe / unsubscribe / select / examine / bboard /
  2540.                        append / x_command
  2541.                        ;; valid only when in authenticated or mailbox open mode
  2542.  
  2543.    request_open    ::= request_authed / check / expunge / copy / fetch /
  2544.                        partial / store / uid / search / x_command
  2545.                        ;; valid only when in mailbox open mode
  2546.  
  2547.    response        ::= tag SPACE ("OK" / "NO" / "BAD") SPACE response_text CRLF
  2548.  
  2549.    response_code   ::= "PARSE" / "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
  2550.                        "UNSEEN" / "X" atom / kerberos_response
  2551.  
  2552.    response_text   ::= ("[" response_code "]" SPACE text_line) /
  2553.                        ("[UNSEEN]" SPACE number SPACE text_line) / text_line
  2554.  
  2555.    search          ::= "SEARCH" SPACE 1#("ALL" / "ANSWERED" /
  2556.                        "BCC" SPACE istring / "BEFORE" SPACE day /
  2557.                        "BODY" SPACE istring / "CC" SPACE istring / "DELETED" /
  2558.                        "FLAGGED" / "FROM" space istring /
  2559.                        "KEYWORD" SPACE user_flag / "NEW" / "OLD" /
  2560.                        "ON" SPACE day / "RECENT" / "SEEN" /
  2561.                        "SINCE" SPACE day / "SUBJECT" SPACE istring /
  2562.                        "TEXT" SPACE istring / "TO" SPACE istring /
  2563.                        "UNANSWERED" / "UNDELETED" / "UNFLAGGED" /
  2564.                        "UNKEYWORD" SPACE user_flag / "UNSEEN")
  2565.  
  2566.    select          ::= "SELECT" SPACE mailbox
  2567.  
  2568.    sequence        ::= number / (sequence "," sequence) / (number ":" number)
  2569.                        ;; identifies a set of messages by consecutive numbers
  2570.                        ;; from 1 to the number of messages in the mailbox.
  2571.                        ;; Comma delimits individual numbers, colon delimits
  2572.                        ;; between two numbers inclusive.
  2573.                        ;; Example: 2,4:7,9,12:15 is 2,4,5,6,7,9,12,13,14,15
  2574.  
  2575.  
  2576.  
  2577.  
  2578. Crispin                                                        [Page 46]
  2579.  
  2580. Internet Draft                  IMAP2bis              September 30, 1993
  2581.  
  2582.  
  2583.    SPACE           ::= <ASCII SP, space, 0x20>
  2584.  
  2585.    specials        ::= "(" / ")" / "{" / qspecials
  2586.  
  2587.    store           ::= "STORE" SPACE sequence SPACE store_att
  2588.  
  2589.    store_att       ::= "+FLAGS" SPACE flags / "-FLAGS" SPACE flags /
  2590.                        "FLAGS" SPACE flags
  2591.  
  2592.    string          ::= quoted_string / literal
  2593.  
  2594.    subscribe       ::= subscribe_mailbox / subscribe_bboard
  2595.  
  2596.    subscribe_bboard
  2597.                    ::= "SUBSCRIBE" SPACE "BBOARD" SPACE mailbox_bboard
  2598.  
  2599.    subscribe_mailbox
  2600.                    ::= "SUBSCRIBE" SPACE "MAILBOX" SPACE mailbox
  2601.  
  2602.    system_flag     ::= "\ANSWERED" / "\FLAGGED" / "\DELETED" / "\SEEN" /
  2603.                        system_flag_new
  2604.  
  2605.    system_flag_new ::= "\" atom
  2606.                        ;; future expansion
  2607.  
  2608.    tag             ::= 1*<any CHAR except "*", specials, SPACE, and CTLs>
  2609.  
  2610.    text_line       ::= 1*<any CHAR except CR and LF>
  2611.  
  2612.    time            ::= 2DIGIT ":" 2DIGIT ":" 2DIGIT
  2613.                        ;; hours minutes seconds
  2614.  
  2615.    uid             ::= "UID" SPACE (uid_after / copy / fetch / store)
  2616.                        ;; uniqueids used instead of message numbers
  2617.  
  2618.    uid_after       ::= "AFTER" SPACE uniqueid
  2619.  
  2620.    uniqueid        ::= number
  2621.                        ;;; strictly ascending
  2622.  
  2623.    unsolicited     ::= "*" SPACE (human_data / mailbox_data /
  2624.                        message_data) CRLF
  2625.  
  2626.    unsubscribe     ::= unsubscribe_mailbox / unsubscribe_bboard
  2627.  
  2628.    unsubscribe_bboard
  2629.                    ::= "UNSUBSCRIBE" SPACE "BBOARD" SPACE mailbox_bboard
  2630.  
  2631.  
  2632.  
  2633.  
  2634. Crispin                                                        [Page 47]
  2635.  
  2636. Internet Draft                  IMAP2bis              September 30, 1993
  2637.  
  2638.  
  2639.    unsubscribe_mailbox
  2640.                    ::= "UNSUBSCRIBE" SPACE "MAILBOX" SPACE mailbox_mailbox
  2641.  
  2642.    userid          ::= astring
  2643.  
  2644.    user_flag       ::= atom
  2645.  
  2646.    x_command       ::= "X" atom <optional arguments>
  2647.                        ;; experimental expansion commands
  2648.  
  2649.    zone            ::= ("+" / "-") 4DIGIT
  2650.                        ;; Signed four-digit value of hhmm representing
  2651.                        ;; hours and minutes west of Greenwich (that is,
  2652.                        ;; (the amount that the given time differs from
  2653.                        ;; Universal Time).  Subtracting the timezone
  2654.                        ;; from the given time will give the UT form.
  2655.                        ;; The Universal Time zone is "+0000".
  2656.  
  2657.    zone_old        ::= "UT" / "GMT" / "Z" /                ;; +0000
  2658.                        "AST" / "EST" / "CST" / "MST" /     ;; -0400 to -0700
  2659.                        "PST" / "YST" / "HST" / "BST" /     ;; -0800 to -1100
  2660.                        "ADT" / "EDT" / "CDT" / "MDT" /     ;; -0300 to -0600
  2661.                        "PDT" / "YDT" / "HDT" / "BDT" /     ;; -0700 to -1000
  2662.                        "A" / "B" / "C" / "D" / "E" / "F" / ;; +0100 to +0600
  2663.                        "G" / "H" / "I" / "K" / "L" / "M" / ;; +0700 to +1200
  2664.                        "N" / "O" / "P" / "Q" / "R" / "S" / ;; -0100 to -0600
  2665.                        "T" / "U" / "V" / "W" / "X" / "Y"   ;; -0700 to -1200
  2666.                        ;; Obsolete
  2667.  
  2668.    A protocol session is as follows:
  2669.  
  2670.     Server: greeting
  2671.     *<Client: request (first part, if it contains a literal)
  2672.       *<Server: ready
  2673.         Client: request (next part)
  2674.        >
  2675.       Server: *<unsolicited>
  2676.       Server: response
  2677.      >
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690. Crispin                                                        [Page 48]
  2691.  
  2692. Internet Draft                  IMAP2bis              September 30, 1993
  2693.  
  2694.  
  2695. Compatibility Notes
  2696.  
  2697.    This is a summary of hints and recommendations to enable an IMAP2bis
  2698.    implementation, written to this specification, to interoperate with
  2699.    implementations that conform to earlier specifications.  None of
  2700.    these hints and recommendations are required by this specification;
  2701.    implementors must decide for themselves whether they want their
  2702.    implementation to fail if it encounters old software.
  2703.  
  2704.    IMAP2bis has been designed to be upwards compatible with earlier
  2705.    specifications.  IMAP2bis facilities that were not in earlier
  2706.    specifications should be invisible to clients unless the client asks
  2707.    for the facility.
  2708.  
  2709.    This information may not be complete; it reflects current knowledge
  2710.    of server and client implementations as well as "folklore" acquired
  2711.    in the evolution of the protocol.
  2712.  
  2713.       IMAP2bis client interoperability with old servers
  2714.  
  2715.       In general, a client should be able to discover whether a server
  2716.       supports a facility by trial-and-error; if an attempt to use a
  2717.       facility generates a BAD response, the client can assume that the
  2718.       server does not support the facility.
  2719.  
  2720.       Some servers may disable certain commands as a matter of
  2721.       intentional site policy.  For example, a bboard-only server may
  2722.       disable the SELECT command.  Such servers should return a NO
  2723.       response to disabled commands instead of a BAD response.
  2724.  
  2725.       A quick way to check whether a server implementation supports this
  2726.       specification is to try a UID FETCH 0 UID command.  An OK or NO
  2727.       response would indicate a server that conforms to this
  2728.       specification; a BAD response would indicate an older server.
  2729.  
  2730.          The CREATE, DELETE, and RENAME commands are new in IMAP2bis,
  2731.          and may not be present in old servers.  A safe mechanism to
  2732.          test whether these commands are present is to try a CREATE
  2733.          INBOX command.  If the response is NO, these commands are
  2734.          supported by the server.  If the response is BAD, they are not.
  2735.          If the response is OK, the server's implementation is broken,
  2736.          since creating INBOX is not permitted.
  2737.  
  2738.          The FIND MAILBOXES and FIND BBOARDS commands are new in RFC
  2739.          1176.  A BAD response to these commands indicates a server that
  2740.          does not support any form of FIND.  It also indicates a server
  2741.          that does not support SUBSCRIBE and UNSUBSCRIBE.  Note that the
  2742.          definition of the FIND MAILBOXES and FIND BBOARDS commands in
  2743.  
  2744.  
  2745.  
  2746. Crispin                                                        [Page 49]
  2747.  
  2748. Internet Draft                  IMAP2bis              September 30, 1993
  2749.  
  2750.  
  2751.          RFC 1176 differs from the definition in this specification; in
  2752.          RFC 1176 these commands were defined as returning a list of
  2753.          mailboxes or bulletin boards with no clear specification of
  2754.          whether the returned values were "subscribed" or "all possible"
  2755.          names.
  2756.  
  2757.          The FIND ALL.MAILBOXES and FIND ALL.BBOARDS commands are new in
  2758.          IMAP2bis.  A BAD response to these commands indicates a server
  2759.          that does not support a concept of subscriptions to a mailbox
  2760.          or bulletin board.  The server may support FIND MAILBOXES and
  2761.          FIND BBOARDS using the older RFC 1176 semantics.
  2762.  
  2763.          The SUBSCRIBE and UNSUBSCRIBE commands are new in IMAP2bis.  A
  2764.          server that supports FIND ALL.MAILBOXES and FIND ALL.BBOARDS
  2765.          will also support the SUBSCRIBE and UNSUBSCRIBE commands.
  2766.  
  2767.          The EXAMINE command is new in IMAP2bis.  A BAD response to this
  2768.          command indicates a server that does not support an explicit
  2769.          read-only mode of access, and a SELECT command should be used
  2770.          instead.
  2771.  
  2772.          Older server implementations may automatically create the
  2773.          destination mailbox on COPY if that mailbox does not already
  2774.          exist.  This was how a new mailbox was created in older
  2775.          specifications.  If the server does not support the CREATE
  2776.          command (see above for how to test for this), it will probably
  2777.          create a mailbox on COPY.
  2778.  
  2779.          The APPEND command is new in IMAP2bis.  A way to see if this
  2780.          command is implemented is to try to append a zero-length stream
  2781.          to a mailbox name that is known not to exist (or at least,
  2782.          highly unlikely to exist) on the remote system.
  2783.  
  2784.          Although IMAP2bis clients SHOULD avoid asking for the same data
  2785.          more than once (by having a client-based cache of data returned
  2786.          by the server), this is not a requirement of the protocol.
  2787.          However, IMAP2bis clients MUST cache data from the EXISTS and
  2788.          RECENT unsolicited responses.  Only the SELECT command is
  2789.          guaranteed to return EXISTS/RECENT information.
  2790.  
  2791.          The BODY, BODY[section], and FULL fetch data items are new in
  2792.          IMAP2bis.  A BAD response to an attempt to fetch either data
  2793.          item indicates a server that does not support server-based MIME
  2794.          parsing.
  2795.  
  2796.          The BODYSTRUCTURE fetch data item is new in IMAP2bis.  A BAD
  2797.          response to an attempt to fetch this data item indicates a
  2798.          server that does not support extensible results from server-
  2799.  
  2800.  
  2801.  
  2802. Crispin                                                        [Page 50]
  2803.  
  2804. Internet Draft                  IMAP2bis              September 30, 1993
  2805.  
  2806.  
  2807.          based MIME parsing.  The server may be running an earlier,
  2808.          experimental version of IMAP2bis and support the older, non-
  2809.          extensible, BODY fetch data item.  A client should attempt this
  2810.          data item before deciding that the server does not support
  2811.          MIME.
  2812.  
  2813.          The use of nested part 0 of a part of type MESSAGE in a BODY or
  2814.          BODYSTRUCTURE fetch to get only the RFC 822 header of the
  2815.          message is new, and is not in earlier, experimental versions of
  2816.          IMAP2bis.  A server that returns NIL is probably running the
  2817.          earlier version; with such servers the only way to obtain the
  2818.          RFC 822 header is to fetch the entire nested message.
  2819.  
  2820.          The RFC822.HEADER.LINES and RFC822.HEADER.LINES.NOT fetch data
  2821.          items are new in IMAP2bis.  A BAD response to an attempt to
  2822.          fetch this data item indicates a server that does not support
  2823.          selective header fetching.  A client should use RFC822.HEADER
  2824.          and remove the unwanted information.
  2825.  
  2826.          The UID fetch data item and the UID commands are new in
  2827.          IMAP2bis.  A BAD response to an attempt to use these indicates
  2828.          a server that does not support unique identifiers.
  2829.  
  2830.          The PARTIAL command is new in IMAP2bis.  If this command causes
  2831.          a BAD response, then the client should use the appropriate
  2832.          FETCH command and ignore the unwanted data.
  2833.  
  2834.          IMAP2bis client implementations must accept all responses and
  2835.          data formats documented in this specification, including those
  2836.          labeled as obsolete.  This includes the COPY and STORE
  2837.          unsolicited responses and the old format of dates and times.
  2838.  
  2839.          Older server implementations may not provide a way to set flags
  2840.          on APPEND.  Client implementations which receive a BAD response
  2841.          to an APPEND command with flags should retry the command
  2842.          without flags.
  2843.  
  2844.          Older server implementations may not preserve flags on COPY.
  2845.          Some server implementations may not permit the preservation of
  2846.          certain flags on COPY or their setting with APPEND as site
  2847.          policy.  Older server implementations may attempt to preserve
  2848.          the internal date on COPY, and may cause a mailbox to be
  2849.          ordered in other than strictly ascending internal date/time
  2850.          order.  Client implementations should not depend on any of
  2851.          these behaviors.
  2852.  
  2853.          Older server implementations may send a TRYCREATE special
  2854.          information token inside a separate unsolicited OK response
  2855.  
  2856.  
  2857.  
  2858. Crispin                                                        [Page 51]
  2859.  
  2860. Internet Draft                  IMAP2bis              September 30, 1993
  2861.  
  2862.  
  2863.          instead of inside the NO response.
  2864.  
  2865.       IMAP2bis server interoperability with old clients
  2866.  
  2867.       In general, there should be no interoperation problem between a
  2868.       server conforming to this specification and a well-written client
  2869.       that conforms to an earlier specification.  Known problems are
  2870.       noted below:
  2871.  
  2872.          Clients written to use undocumented private server extensions
  2873.          that are not in any published specification may work poorly
  2874.          with server implementations that do not have those extensions.
  2875.  
  2876.          Poor wording in the description of the CHECK command in earlier
  2877.          specifications implied that a CHECK command is the way to get
  2878.          the current number of messages in the mailbox.  This is
  2879.          incorrect.  A CHECK command does not necessarily result in an
  2880.          EXISTS response.  Clients must remember the most recent EXISTS
  2881.          value sent from the server, and should not generate unnecessary
  2882.          CHECK commands.
  2883.  
  2884.          An incompatibility exists with COPY in IMAP2bis.  COPY in
  2885.          IMAP2bis servers does not automatically create the destination
  2886.          mailbox if that mailbox does not already exist.  This may cause
  2887.          problems with old clients that expect automatic mailbox
  2888.          creation in COPY.
  2889.  
  2890.          The PREAUTH unsolicited response is new in IMAP2bis.  It is
  2891.          highly unlikely that an old client would ever see this
  2892.          response.
  2893.  
  2894.          The COPY unsolicited response is obsolete.  Old clients must
  2895.          not depend on receiving this response.
  2896.  
  2897.          The STORE unsolicited response is obsolete.  Old clients must
  2898.          not object to receiving a FETCH response instead of this
  2899.          response.
  2900.  
  2901.          The format of dates and times has changed.  Old clients should
  2902.          accept a four-digit year instead of a two-digit year, and a
  2903.          signed four-digit timezone value instead of a timezone name.
  2904.          In particular, client implementations must not treat a
  2905.          date/time as a fixed format string and assumed that the time
  2906.          begins at a particular octet.
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914. Crispin                                                        [Page 52]
  2915.  
  2916. Internet Draft                  IMAP2bis              September 30, 1993
  2917.  
  2918.  
  2919. Acknowledgements
  2920.  
  2921.    Bill Yeager and Rich Acuff contributed invaluable suggestions in the
  2922.    evolution of IMAP2 from the original IMAP.  James Rice pointed out
  2923.    several ambiguities in the previous IMAP2 specification.
  2924.  
  2925.    My colleagues on the Pine team -- Steve Hubert, Laurence Lundblade,
  2926.    David Miller, and Mike Seibel -- worked long and hard to create a
  2927.    fantastic email user agent with worldwide popularity.  Without their
  2928.    efforts, IMAP2 would have languished in obscurity.  Terry Gray, our
  2929.    boss, provided much-needed moral support and guidance, while refusing
  2930.    to let us get away with "good enough" when "great" was possible.
  2931.  
  2932.    John G. Myers and Chris Newman carefully examined the formal grammar
  2933.    and identified numerous mistakes and omissions in the drafts of this
  2934.    specification.  They also provided invaluable input towards the
  2935.    overall architecture of the present protocol, and endured long
  2936.    meetings to reach the present protocol.
  2937.  
  2938.    The present protocol would not have come into existence without the
  2939.    assistance of the rest of the IETF IMAP2 working group, in particular
  2940.    Ned Freed and Adam Treister.
  2941.  
  2942.    Any mistakes, flaws, or sins of omission in this IMAP2bis protocol
  2943.    specification are, however, strictly my own; and the mention of any
  2944.    name above does not imply an endorsement.
  2945.  
  2946. Security Considerations
  2947.  
  2948.    Security issues are discussed in this memo only as far as
  2949.    authentication to access a server are concerned.
  2950.  
  2951. Author's Address
  2952.  
  2953.    Mark R. Crispin
  2954.    Networks and Distributed Computing, JE-30
  2955.    University of Washington
  2956.    Seattle, WA  98195
  2957.  
  2958.    Phone: (206) 543-5762
  2959.  
  2960.    EMail: MRC@CAC.Washington.EDU
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970. Crispin                                                        [Page 53]
  2971.  
  2972.  
  2973.